r - Convert a list of data frames into one data frame -


I have a code that ends with a list of data frames in a place, which I actually do in a bigger data Want to convert frame.

I was given some indications that were trying to do the same but more complex work.

  listOfDataFrames & lt; - For vector (mode = "list", length = 100)  

) (i 1: 100) {listOfDataFrames [[i]] & lt; - data.frame (a = for sample (letter, 500, delegate = t), b = rnorm (500), c = rnorm (500))

i currently Using:

  df  

Another option is a plyr function Use:

  df  

It is slightly slower than the original:

  & gt; System.time ({df & lt; - do.call ("rbind", listOfDataFrames)}) User system has passed 0.25 0.00 0.25 & gt; System.time ({df2 & lt; - ldply (listOfDataFrames, data.frame)}) User system has passed 0.30 0.00 0.29 & gt; Similar (DF, DF2) [1] True  

My guess is that using do.call ("rbind", ...) The fastest way is that you can not do anything until you (A) use a matrix instead of data. Frame and (b) Apply the final matrix in advance and allocate for it instead of increasing it.

Edit 1 :

Based on Headley's comment, here is the latest version of rbind.fill from Crane:

  & gt; System.time ({df3 & lt; - rbind.fill (listOfDataFrames)}) User system has passed 0.24 0.00 0.23 & gt; Similar (DF, DF3) [1] True  

It is easier than RBID, and is moderately fast (these times are on multiple runs) And as far as I understand it, it is faster than this.


Comments