[R] matrix from list

Olivier Lefevre lefevrol at yahoo.com
Fri Apr 25 00:02:53 CEST 2008


Another possibly simple thing that I cannot get right is how to extract the 
data part of a list as a matrix. The data were read from xls, with labels, 
and thus are of list mode, e.g.,

   col1 col2
1 0.1  1.1
2 0.2  1.2

I want to extract from that just the numeric data part, i.e., (in this 
case) the same thing that matrix(c(0.1, 0.2, 1.1, 1.2), 2, 2) would return. 
I am grasping for a syntax like list[[1:2]] but that doesn't work and I 
can't find anything that does.

Thanks,

-- O.L.



More information about the R-help mailing list