[R] convert list int data frame

Sarah Goslee sarah.goslee at gmail.com
Mon Sep 14 14:50:30 CEST 2015


You don't say how you want the new data frame (which incidentally is
also a list) to be constructed, so here are two options:
> my.list <- replicate(5, matrix(1:(6*27), ncol = 6, byrow = TRUE), FALSE)
> dim(my.list[[1]])
[1] 27  6
> dim(do.call(rbind.data.frame, my.list))
[1] 135   6
> dim(do.call(cbind.data.frame, my.list))
[1] 27 30

Sarah

On Mon, Sep 14, 2015 at 7:07 AM, Luigi Marongiu
<marongiu.luigi at gmail.com> wrote:
> Dear all,
> i would like to convert a list onto a data frame object. Is there an
> easy way of doing it? I know I should use unlist() but I am not sure
> about the implementation for the addition of the row numbers; or I
> could extract one member at the time with something like x <-
> my.list[[i]] but then how to append the results to an object?
> Thank you.
> Best regards
> Luigi
>
>>>>
> my.list <- replicate(5, matrix(1:(6*27), ncol = 6, byrow = TRUE), FALSE)
>


-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list