[R] rbind data frames stored in a list

Dimitri Liakhovitski ld7631 at gmail.com
Thu Apr 23 03:36:10 CEST 2009


Hello everyone!

I have a list X with 3 elements, each of which is a data frame, for example:

a<-data.frame(a=1,b=2,c=3)
b<-data.frame(a=c(4,7),b=c(5,8),c=c(6,9))
c<-data.frame(a=c(10,13,16),b=c(11,14,17),c=c(12,15,18))
X<-list()
X[[1]]<-a
X[[2]]<-b
X[[3]]<-c
(X)

How can I most effectively transform X into a data frame with columns
a, b, and c?
I would love to find a generic solution, and not a specific solution
like this one:

frame<-rbind(X[[1]],X[[2]],X[[3]])

...because in reality I have a lot of elements of X.

Thank you very much!

-- 
Dimitri Liakhovitski
MarketTools, Inc.
Dimitri.Liakhovitski at markettools.com




More information about the R-help mailing list