有谁知道如何在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
我想可能有更好的方法。谢谢!