[R] list to Matrix

Markus Schmidberger schmidb at ibe.med.uni-muenchen.de
Fri Nov 2 10:35:57 CET 2007


Hello,

I have a list of vectors (all the same length). How to convert the list 
to a matrix? Each vector should be a column.
I tried this:

l <- list(c(1,2,3),c(1,2,3),c(1,2,3))
mat <- matrix( unlist(l), nrow=length(l) )

But I think this is not very efficient. Is there a better solution?

Thanks
Markus

-- 
Dipl.-Tech. Math. Markus Schmidberger

Ludwig-Maximilians-Universität München
IBE - Institut für medizinische Informationsverarbeitung,
Biometrie und Epidemiologie
Marchioninistr. 15, D-81377 Muenchen
URL: http://ibe.web.med.uni-muenchen.de 
Mail: Markus.Schmidberger [at] ibe.med.uni-muenchen.de



More information about the R-help mailing list