s-news
[Top] [All Lists]

Re: list manipulation- an Easy method to do rbind within a

To: "Steve Su" <s.su@qut.edu.au>
Subject: Re: list manipulation- an Easy method to do rbind within a
From: John Fox <jfox@mcmaster.ca>
Date: Sun, 27 Oct 2002 09:50:16 -0500
Cc: <s-news@lists.biostat.wustl.edu>
In-reply-to: <000001c27db9$c1ad0a40$4f32b583@busacc325>
Dear Steve,

At 11:07 PM 10/27/2002 +1000, Steve Su wrote:
Lets suppose we have the following list:

list(matrix(rnorm(6,3,2),ncol=2),matrix(rnorm(8,3,2),ncol=2),matrix(rnorm(12,3,2),ncol=2))

[[1]]:
         [,1]      [,2]
[1,] 3.276729 -1.054961
[2,] 6.143453  2.661098
[3,] 3.952712  5.311158

[[2]]:
         [,1]     [,2]
[1,] 2.575617 2.513717
[2,] 1.657351 2.806912
[3,] 3.134966 3.357252
[4,] 3.832333 7.657893
 

[[3]]:
          [,1]       [,2]
[1,]  4.171555 1.67055950
[2,] -1.763487 1.42753060
[3,]  4.552255 2.78249251
[4,] -3.206052 0.49597245
[5,] -1.742525 4.01679075
[6,]  2.486436 0.05678951
 

What is the most efficient way to combine these three elements into one matrix with two columns and 13 rows? Is there a simple and effective solution to this? My solution is quite complicated for the small problem at hand so I would appreciate any input J

Try
        lst <- list(matrix(rnorm(6,3,2),ncol=2), matrix(rnorm(8,3,2),ncol=2), matrix(rnorm(12,3,2),ncol=2))
        do.call("rbind", lst)

I hope that this helps,
 John

-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox@mcmaster.ca
phone: 905-525-9140x23604
-----------------------------------------------------
<Prev in Thread] Current Thread [Next in Thread>