有谁知道如何在rbind.fill
函数中保留rownames。在R中使用rbind.fill时保留行名称
library(plyr)
#creating data
a <- mtcars[ 1:5 , c("mpg","hp","gear") ]
b <- mtcars[ 6:10 , c("mpg","disp","gear") ]
#does not work because there are different colnames
rbind(a,b)
#works but eliminates the rownames
bound <- rbind.fill(a , b)
我正在设置一个循环,其中将使用rbind.fill
连接对象。现在我正在使用这样的组合功能:
namess <- c(rownames(a) , rownames(b))
rownames(bound) <- namess
我认为可能有更好的方法。谢谢!
我会认为这是一个错误。我不知道'plyr'是否有bug报告论坛/地点,但是如果有人应该链接到它,并且应该提交这个文件。 – eddi 2013-05-07 15:19:43
@eddi同意:)我刚刚在github上提交了它https://github.com/hadley/plyr/issues/156 – 2013-05-07 15:21:34
Plyr不支持行名称。把它们放在一个变量中,然后明确地处理它们是一个更好的主意。 – hadley 2013-05-07 15:29:24