I found a great function someone wrote here, to merge >2 dataframes in R. However, when I use it on dataframes with column headers, the headers are erased and replaced with "X1", "X2", etc.
x<-matrix(1:10,5,2)
y<-matrix(1:16, 4,4)
z<-matrix(1:12, 2,6)
require(plyr) # requires plyr for rbind.fill()
cbind.fill <- function(...) {
transpoted <- lapply(list(...),t)
transpoted_dataframe <- lapply(transpoted, as.data.frame)
return (data.frame(t(rbind.fill(transpoted_dataframe))))
}
cbind.fill(x,y,z)
Sorry that I don't have an example with actual column names!