Inner join
Join data where records present in both data sets

alldata <-
table2[table1, on = c(table2linkvar = 'table1linkvar'),
nomatch = NULL]Leave out the nomatch argument) and you get a left [outer] join of table2 on table1.

The ordering in the code is a bit counterintuitive.
Apply a function to multiple columns in place
e.g. replace all missing/blank values with zero
numdenom <- c('varname1', 'varname2')
alldata[, eval(numdenom) := lapply(.SD,
function(x)
# the function
ifelse(is.na(x) | x %in% '', 0, as.integer(x))
),
.SDcols = numdenom]