Glad to see 1.11.0 version is just released. I noticed from NEWS that with= will be slowly deprecated in future versions (as thoroughly discussed in #2655). However, I find it less obvious for the following cases:
library(data.table)
dt <- data.table(x1 = 1:5, x2 = 5:1, y1 = 0:4, y2 = 4:0)
selector <- list(x = c("x1", "x2"), y = c("y1", "y2"))
To use selector$x or selector$y to select columns in dt, with argument is more obvious.
dt[, selector$x, with = FALSE]
But if with= is no longer available, it seems that we can only store selector$x in another symbol that allows direct access to do the same.
selector_x <- selector$x
dt[, ..selector_x]
Another similar case is calling a function to get the column names we need:
f <- function(prefix, n) {
paste0(prefix, 1:n)
}
dt[, f("x", 2), with = FALSE]
I'm not sure if I'm missing something new in the latest release but these cases can be ugly without with argument. If .. has to be applied to these cases, it seems that all ..symbol is needed to be directed to symbol in the calling scope (#2589) so that something like dt[, ..selector$x] or dt[, ..f("x")] work.
Glad to see
1.11.0version is just released. I noticed fromNEWSthatwith=will be slowly deprecated in future versions (as thoroughly discussed in #2655). However, I find it less obvious for the following cases:To use
selector$xorselector$yto select columns indt,withargument is more obvious.But if
with=is no longer available, it seems that we can only storeselector$xin another symbol that allows direct access to do the same.Another similar case is calling a function to get the column names we need:
I'm not sure if I'm missing something new in the latest release but these cases can be ugly without
withargument. If..has to be applied to these cases, it seems that all..symbolis needed to be directed tosymbolin the calling scope (#2589) so that something likedt[, ..selector$x]ordt[, ..f("x")]work.