I have two data.tables with many fields.
I want to join the two tables, add some calculated fields and append all other fields from the first, second or both tables (similar to SQL's select a+b AS sum, DT1.*, DT2.* FROM...
) without typing all the field names.
How can I do this (regarding easiest syntax and best performance)?
Simplified example data:
library(data.table)
DT1 = data.table(x=c("c", "a", "b", "a", "b"), a=1:5)
DT2 = data.table(x=c("d", "c", "b"), b=6:8)
Now I want to join the tables and add a calculated field:
DT1[DT2, .(sum=a + b, <<< how to say DT1.*, DT2.* here? >>> ), on="x"]
Update May 4, 2016: Inspired by user jangorecki I have found a feature request for this: