[R] who to rbind of a list of data.frames

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Tue Aug 12 10:53:24 CEST 2003


lutz.thieme at amd.com writes:

> Hello everybody,
> 
> could anybody give me a hint, who I can use rbind on a list of data.frames, please?
> 
> I have a list with a large number of data.frames of the same structure, like:
> LIST	<- list(X1=data.frame(a=1,b=2), X2=data.frame(a=3,b=4), X3=data.frame(a=5,b=6), ...., XN=data.frame(a=i,b=k))
> 
> I would like to bind all data.frames very fast to a single data.frame, something like that:
> DF	<- rbind(LIST$X1, LIST$X2, LIST$X3, ..., LIST$XN)
> 
> But for performance (speed) reasons I won't use a loop. I also couldn't find a solution how 
> I could use lapply. One constraint is, that the number of data.frames in the list is not determined 
> and can vary from one to more than thousand. 
> Any help is apreciated, thank you in advance.

Bill V.'s favourite trick:

do.call("rbind", LIST)

> 	Lutz Thieme
> 	Product Engineering
> 	AMD Saxony Limited Liability Company & Co. KG

Anyone tried getting R to run on Opterons in 64 bit mode BTW? Those
machines are quickly approaching Xeon prices around here..

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list