[R] How to convert a list to a matrix
Jean Eid
jeaneid at chass.utoronto.ca
Thu Feb 3 16:50:09 CET 2005
list1 <- list(x=c(1,2), y=c(3,4), z=c(4,5))
matrix(unlist(list1), nrow=length(list1), byrow=T)
HTH
On Thu, 3 Feb 2005, michael watson (IAH-C) wrote:
> 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