Merging multiple data.tables Merging multiple data.tables r r

Merging multiple data.tables


Not sure, but maybe (untested) :

Reduce(merge,list(DT1,DT2,DT3,...))


To flesh out the solution suggested by @Henk in comments, here is how to use this to select the all = TRUE option in a concise formulation:

MergedDT = Reduce(function(...) merge(..., all = TRUE), List_of_DTs)


The latest version of data.table (1.10.5) has an easy syntax for table join, which can also be chained.

 set(DT1, key) set(DT2, key)   ... set(DT10, key) DT_cmb <- DT1[DT2,][DT3,]...[DT10,]