I have two data.tables, and one has a subset of rows/columns of another. I\'d like to add values of the smaller data.table to the values of the larger one:
D
You can use rbindlist() to bring the two together, then sum the values based on rn
rbindlist()
rn
rbindlist(list(DT1, DT2), fill=TRUE)[, lapply(.SD, sum, na.rm = TRUE), by = rn] # rn a b c # 1: a 0 4 1 # 2: b 1 5 0 # 3: c 1 1 3