Skip to content
Prev 318450 / 398503 Next

merging or joining 2 dataframes: merge, rbind.fill, etc.?

Hi:

The other day I ran 100K simulations, each of which returned a 20 x 4
data frame. I stored these in a list object. When attempting to rbind
them into a single large data frame, my first thought was to try plyr:

library(plyr)
bigD <- ldply(L, rbind)   # where L is the list object

I quit at around a half hour. Ditto for do.call(rbind, L). [Sorry, I
didn't time it - these are approximate times.] I then checked to see
if the data.table package could do this, and lo and behold, I
discovered the rbindlist() function. When applied to my list object,
it ran correctly in under a second. Here's the actual example with
some names changed to mask the application:

g <- gs[1:100000]   # gs is a list of lists
[1] 100000
[1] "list"
[1] 20  4
[1] 20  4
user  system elapsed
   0.45    0.02    0.47
[1] 2000000       4
[1] "data.table" "data.frame"

Dennis
On Tue, Feb 26, 2013 at 7:05 PM, David Kulp <dkulp at fiksu.com> wrote: