s-news
[Top] [All Lists]

How to cbind a list to data.frame while avoid using for loop

To: <s-news@lists.biostat.wustl.edu>
Subject: How to cbind a list to data.frame while avoid using for loop
From: "Brian Wu" <bwu@guzman.com>
Date: Thu, 16 Feb 2006 13:55:08 -0500
Thread-index: AcYy9rH1PgXUYSbqQIGew362sW3OjgAMv4jA
Thread-topic: [S] multivariate test for homogeneity of variances
I have a list temp.

> temp
[[1]]
      MSFT
1999 37156
2000 52150
2001 59257
2002 67646
2003 79571
2004 92389

[[2]]
        IBM
1999  87495
2000  88349
2001  88313
2002  96484
2003 104457
2004 109183

[[3]]
         GOOG
1999       NA
2000       NA
2001       NA
2002  286.892
2003  871.458
2004 3313.351

Any idea, how to combine the data.frame components into a data.frame avoid 
using for loop?

I wanna the result like this:
> cbind(temp[[1]],temp[[2]],temp[[3]])
      MSFT    IBM     GOOG
1999 37156  87495       NA
2000 52150  88349       NA
2001 59257  88313       NA
2002 67646  96484  286.892
2003 79571 104457  871.458
2004 92389 109183 3313.351

the length of the list is variable.

Any suggestion will be greatly appreciated!

Brian



<Prev in Thread] Current Thread [Next in Thread>