How can I subset column a and b using column1 and column2 character vectors? Example below
library(data.table)
df <- data.table(a = c(1, 2, NA, 3), b = c(6:9))
column1 <- 'a'
column2 <- 'b'
df[is.na(column1), column2, with = F]
# Desired output
df[is.na(a), .(b)]