[R] How to convert a list to a matrix

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.ac.be
Thu Feb 3 16:34:24 CET 2005


try this:

mat <- matrix(unlist(lis), ncol=2, byrow=TRUE)

I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "michael watson (IAH-C)" <michael.watson at bbsrc.ac.uk>
To: <r-help at stat.math.ethz.ch>
Sent: Thursday, February 03, 2005 4:08 PM
Subject: [R] How to convert a list to a matrix


> Hi
>
> Sorry to ask such a basic question.  I have a list, each element of
> which is a vector of two values.  What I actually want is a matrix 
> with
> two columns, and one row per element of the list.  Obviously I have
> tried as.matrix(), and as.vector() but I didn't expect the latter to
> work.
>
> I feel so lame asking this.  Any suggestions?
>
> Mick
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list