I want to add multiple sets of columns (numeric) from tbl.male and tbl.female to tbl.total using for-loop.
The code is:
for ( i in c(4:17){
tbl.total[,i] <- tbl.male[,i] + tbl.female[,i]
}
Error warning:
Error in `[.data.table`(tbl.female, , i) :
j (the 2nd argument inside [...]) is a single symbol but column name 'i' is not found. Perhaps you intended DT[, ..i]. This difference to data.frame is deliberate and explained in FAQ 1.1.