[R] Quick data-manipulation question

Liaw, Andy andy_liaw at merck.com
Thu Oct 28 15:47:09 CEST 2004


I do not know of a better way than to do something like do.call("rbind",
listOfDataFrame).  This will take a while because rbind.data.frame needs to
check and make sure the result is a valid data.frame (e.g., rownames need to
be unique).  If all the columns are of the same type, you might find it
faster to coerce to matrices, rbind, then coerce back to data.frame.

HTH,
Andy

> From: Sean Davis
> 
> I have a list of data frames and I want to concatenate them into a 
> single data frame, basically appending all of the data frames to each 
> other (they are all the same shape, in terms of columns).  
> I'm looking 
> for a nice way to do that.  I can of course just consecutively rbind 
> them to a "master" dataframe, but I have 22,000 such data 
> frames, each 
> with a few hundred rows, so this process takes a good while.  
> Should be 
> simple, I imagine....
> 
> Here is a toy data structure.
> j <- list()
> for (i in letters[1:26]) {j[[i]] <- 
> data.frame(rep(i,25),matrix(rnorm(250),nrow=25))}
> 
> Thanks.
> 
> Sean
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>




More information about the R-help mailing list