Skip to content
Prev 246576 / 398506 Next

How to join matrices of different row length from a list

try this:

matLis <- list(matrix(1:4, 2, 2), matrix(1:6, 3, 2),
     matrix(2:1, 1, 2))

n <- max(sapply(matLis, nrow))
do.call(cbind, lapply(matLis, function (x)
     rbind(x, matrix(, n-nrow(x), ncol(x)))))


I hope it helps.

Best,
Dimitris
On 1/6/2011 11:56 AM, emj83 wrote: