I got a list of matrices X rows by 2 columns, called list_of_matrices_by2
list_of_matrices_by2[1:3]
[[1]]
[,1] [,2]
[1,] "7204" "d"
[2,] "7204" "a"
[[2]]
[,1] [,2]
[1,] "2032" "b"
[2,] "2032" "e"
[3,] "2032" "a"
[[3]]
[,1] [,2]
[1,] "802" "d"
[2,] "802" "b"
I want to stack all my matrices in a all_pairs matrix, so I did this
all_pairs=do.call(rbind,list_of_matrices_by2)
all_pairs[1:10]
[,1] [,2]
[1,] "7204" "d"
[2,] "7204" "a"
[3,] "2032" "b"
[4,] "2032" "e"
[5,] "2032" "a"
[6,] "802" "d"
[7,] "802" "b"
[8,] "4674" "c"
[9,] "4674" "a"
[10,] "3886" "b"
class(all_pairs)
[1] "matrix"
For some reason, I need the rows of this matrix to be of class matrix. But it shouldn't be a problem since rows of matrix are matrix in R, right. But no!
all_pairs[1,]
[[1]]
[1] "7204"
[[2]]
[1] "d
So here are my questions : 1) Why this? How come a row of a matrix can possibly be a list? 2) What would you do to make it work, i.e. each row of my matrix has to be a matrix?