DT <- data.table(a=1:2, b=c("x", "y"))
DT[, get("a")]
#[1] 1 2
DT[, mget("a", inherits = TRUE)]
#Error: value for ‘a’ not found
It works if the correct environment is specified:
DT[, mget("a", as.environment(.SD))]
# a
#1: 1
#2: 2
According to Arun:
The j-exp is parsed and checked for get(), but not mget(). Therefore the SD environment isn't constructed with the required columns.