[R] applying rbind to list elements

Tony Plate tplate at acm.org
Wed Apr 25 22:16:38 CEST 2007


do.call("rbind", l)

or, in the case of matrices, using the abind package:

abind(l, along=1)

 > library(abind)
 > l <- list(matrix(1:6, ncol=2), matrix(11:14, ncol=2))
 > abind(l, along=1)
      [,1] [,2]
[1,]    1    4
[2,]    2    5
[3,]    3    6
[4,]   11   13
[5,]   12   14
 >

Hendrik Fuß wrote:
> Hi,
> 
> I have a list of n data.frames (or matrices) which I would like to
> convert to a single data.frame using rbind:
> 
>    x <- rbind( l[[1]], l[[2]], l[[3]], l[[4]], ..., l[[n]] )
> 
> Is there a simple way to do this?
> 
> thanks
> Hendrik
>



More information about the R-help mailing list