Skip to content
Prev 171295 / 398506 Next

Convert a list to matrix

one way is the following:

m <- list(A = 1, B = 1:2, C = 1:3, D = 1:4)

n <- max(sapply(m, length))
t(sapply(m, function (x) c(x, rep(NA, n - length(x)))))


I hope it helps.

Best,
Dimitris
Daren Tan wrote: