do.call("cbind", temp) will create a matrix. The original message is unclear
about whether a matrix or data.frame is desired. But if a data.frame,
as.data.frame(temp) will do the trick.
-Scott
Sundar Dorai-Raj wrote:
do.call("cbind", temp)
Brian Wu wrote:
> 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
|