标签: r data.table
如何使用column1和column2字符向量对a和b列进行子集设置?下面的例子
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)]