The more I use it, the more data.table
is replacing dplyr
as my \'goto\' package as the speed it offers is a big plus.
Question
We can use eval(as.name(..
dt[eval(as.name(myCol[1]))> eval(as.name(myCol[2]))]
Or we can specify it in the .SDcols
dt[dt[, .I[.SD[[1]]> .SD[[2]]], .SDcols= myCol]]
Or an option using get
by @thelatemail
dt[get(myCol[1]) > get(myCol[2])]
If there are only two elements, we can also use Reduce
with mget
(a slight variation of @thelatemail's answer)
dt[Reduce('>', mget(myCol))]