More on list to data frame (was: Re: [R] List to Data Frame

Uwe Ligges ligges at statistik.uni-dortmund.de
Wed Sep 18 08:17:09 CEST 2002



Ko-Kang Kevin Wang wrote:
> 
> Hi,
> 
> Now suppose I have just one list called FOO, which has 25 objects, e.g.:
>   [[1]]
>   1 2 3 4 5
>   [[2]]
>   6 7 8 9 10
>   .
>   .
>   .
> 
> And I want to do something like:
>   FRED <- data.frame(cbind(unlist(FOO[[1]]),
>                            unlist(FOO[[2]]),
>                            # ... for all 25 subsets
>                      ))
> 
> Is it possible to do this, without doing unlist(FOO[[i]]) 25 times?

If want to coerce a list with appropriate elements to a data.frame, as in your example, just use
 as.data.frame(FOO).

Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list