Skip to content
Prev 278370 / 398506 Next

how to stack a list of arrays

Try this for the given data: you'll have to modify the group label
trick a bit if row-numbers aren't even for each element of L, but it's
not hard.

L <- list(`0` = matrix(rnorm(6), ncol = 2), `1` = matrix(rnorm(6),
ncol = 2), `2` = matrix(rnorm(6), ncol = 2))
# Generally it's bad form to use numbers for names

cbind(do.call(rbind, L), group = rep(as.double(names(L)), each = nrow(L[[1]]))

Good luck,
Michael

2011/11/23 Ernest Adrogu? <nfdisco at gmail.com>: