Similar questions have been asked here and here and here. However, none seem to help my specific situation. Im trying to merge a bunch of datasets (that are in a list) and turn it into a matrix. But Im trying to merge them by row. So, for example, if we have some data that looks like this:
set.seed(100)
dfList <- NULL
for(i in 1:3){
dfList[[i]] <- data.frame(
x1 = sample(1:10, 3, replace = T),
x2 = sample(1:10, 3, replace = T)
)
}
> dfList
[[1]]
x1 x2
1 10 3
2 7 9
3 6 10
[[2]]
x1 x2
1 7 4
2 6 7
3 6 6
[[3]]
x1 x2
1 2 7
2 7 8
3 7 2
I am trying to merge the datasets by row and turn it into a matrix. What I mean is, the 1st row of my new matrix will come from the 1st row of the 1st data frame in the list. The 2nd row of my new matrix will come from the 1st row of the 2nd data frame in the list... and so on.
So, using the above example, my desired output would look like:
x1 x2
[1,] 10 3
[2,] 7 4
[3,] 2 7
[4,] 7 9
[5,] 6 7
[6,] 7 8
[7,] 6 10
[8,] 6 6
[9,] 7 2
Any suggestions as to how I could do this?