I have some tables Table1
,Table2
,Table3
,Table4
. They have the same number of columns
and rows
and what I want is to merge
them into one big Table
.
I have tried making a list of the tables and then converting it to a matrix
but the output doesn't seem what I want.
l <- list(Table1, Table2, Table3, Table4)
l <- lapply(l, as.data.frame)
m <- matrix(unlist(l), nrow = length(l))
I have also tried to just merge
the four tables using merge(Table1, Table2, Table3, Table4)
but I am not sure about providing the proper arguments and therefore I get an error.
Error in fix.by(by.x, x) :
'by' must specify one or more columns as numbers, names or logical
Calls: merge -> merge.data.frame -> fix.by
I have also tried to write the tables to an external .txt
file and then read from that file a new table.
#write.table(Table1, file = "file.txt", append = TRUE)
#write.table(Table2, file = "file.txt", append = TRUE, col.names=FALSE)
#write.table(Table3, file = "file.txt", append = TRUE, col.names=FALSE)
#write.table(Table4, file = "file.txt", append = TRUE, col.names=FALSE)
However this solution is inadequate for various reasons and I had to drop it.
By the way I would prefer the first solution to somehow work.
Edit: I forgot to mention that all four tables have identical indexes 1,2,3,..,
and same columns names, etc. I am pointing this out because for example cbind
doesn't fit well.
I am pretty sure this is a trivial task but I am stuck. Any help?