[R] Convert a lis to matrix
Manisha Brahmachary
mb3058 at c2b2.columbia.edu
Mon Jun 8 02:38:01 CEST 2009
Thank you, it worked.
-----Original Message-----
From: Bernardo Rangel Tura [mailto:tura at centroin.com.br]
Sent: Sunday, June 07, 2009 6:14 AM
To: Manisha Brahmachary
Cc: r-help at r-project.org
Subject: Re: [R] Convert a lis to matrix
On Sun, 2009-06-07 at 00:14 -0400, Manisha Brahmachary wrote:
> Hello,
>
>
>
> This is an urgent request. I want to convert a list of 3 elements into a
> matrix and I am not sure how to do it.
>
>
>
> The list looks like this:
>
> List of 3
>
> $ : num [1:15364, 1] 0.133 0.622 0.588 1.024 0.583 ...
>
> ..- attr(*, "dimnames")=List of 2
>
> .. ..$ : chr [1:15364] "6420681" "3610072" "2260458" "60689" ...
>
> .. ..$ : NULL
>
> $ : num [1:15364, 1] 3.159 0.265 0.522 1.912 3.380 ...
>
> ..- attr(*, "dimnames")=List of 2
>
> .. ..$ : chr [1:15364] "6420681" "3610072" "2260458" "60689" ...
>
> .. ..$ : NULL
>
> $ : num [1:15364, 1] 3.214 0.277 1.447 1.827 2.054 ...
>
> ..- attr(*, "dimnames")=List of 2
>
> .. ..$ : chr [1:15364] "6420681" "3610072" "2260458" "60689" ...
>
> .. ..$ : NULL
I'm not sure if understood your question, but look this code
a<-list(B=1:3,C=2:4,D=3:5)
matrix(unlist(a),ncol=3)
--
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil
More information about the R-help
mailing list