Re: [R] matrix from list

From: Jorge Ivan Velez <jorgeivanvelez_at_gmail.com>
Date: Thu, 24 Apr 2008 18:10:04 -0400

Hi Olivier,

is this what you want?

x="col1 col2
1 0.1 1.1
2 0.2 1.2"

m=read.table(textConnection(x),header=TRUE) m1=matrix(unlist(m),ncol=2)
m1

[,1] [,2]
[1,]  0.1  1.1
[2,]  0.2  1.2

HTH, Jorge

On Thu, Apr 24, 2008 at 6:02 PM, Olivier Lefevre <lefevrol_at_yahoo.com> wrote:

> 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.
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 24 Apr 2008 - 22:12:41 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 24 Apr 2008 - 22:30:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive