0

I have a list of matrices like this

[[1]]
     [,1] [,2]
[1,]    1    2
[2,]    2    3
[3,]    3    2
[4,]    4    3
[5,]    3    2

[[2]]
     [,1] [,2]
[1,]    1    2
[2,]    2    3
[3,]    3    2

[[3]]
     [,1] [,2]
[1,]    1    2
[2,]    2    3
[3,]    3    2

and I want to converted to a single matrix like below

      [,1] [,2]
 [1,]    1    2
 [2,]    2    3
 [3,]    3    2
 [4,]    4    3
 [5,]    3    2
 [6,]    1    2
 [7,]    2    3
 [8,]    3    2
 [9,]    1    2
[10,]    2    3
[11,]    3    2

How can I do that? I use the unlist function and I don't get any good answers. I am looking for ideas on how to handle this problem. I would appreciate any suggestions on how to proceed.

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
dmaon
  • 58
  • 9

1 Answers1

3

what about:

the_matrices  <- 
    list(matrix(1:2, , 2),
         matrix(1:2, , 2),
         matrix(1:2, , 2)
         )

## > the_matrices
## [[1]]
##      [,1] [,2]
## [1,]    1    2
## 
## [[2]]
##      [,1] [,2]
## [1,]    1    2
## 
## [[3]]
##      [,1] [,2]
## [1,]    1    2


do.call(rbind, the_matrices)
##      [,1] [,2]
## [1,]    1    2
## [2,]    1    2
## [3,]    1    2
I_O
  • 4,983
  • 2
  • 2
  • 15