Using dynamically determined symbol in j can be quite annoying (as discussed in #633, #2589).
I'm not sure if the following idea makes sense, which seems easier to implement and nicer to look at for me.
library(data.table)
dt <- data.table(id = rep(1:2, 5), x1 = rnorm(10), x2 = rnorm(10), y1 = rnorm(10), y2 = rnorm(10))
dt[, .(xsum = sum(x), ysum = sum(y)), by = id, alias = c(x = "x1", y = "y2")]
In the above example, if a new argument like alias is introduced, a named character vector would give fixed names to dynamically determined symbols, which makes it much easier to use them in j.
Some new problems may occur such as when x or y are already defined in dt. But the syntax looks much cleaner if the dynamic symbols can be determined outside dt.
Using dynamically determined symbol in
jcan be quite annoying (as discussed in #633, #2589).I'm not sure if the following idea makes sense, which seems easier to implement and nicer to look at for me.
In the above example, if a new argument like
aliasis introduced, a named character vector would give fixed names to dynamically determined symbols, which makes it much easier to use them inj.Some new problems may occur such as when
xoryare already defined indt. But the syntax looks much cleaner if the dynamic symbols can be determined outsidedt.