You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use := together with .SD, .SDcols and get(), for example,
dt[, z:= ncol(.SD) + get("y"), .SDcols="x"]
The first time is ok, but whenever z already exists, the code above will produce incorrect results since .SD includes both x and z, which should be x only, as restricted by .SDcols.
The following code is a minimal example and demonstrates the problem:
The problem is that inside [.data.table, it detects all symbols used in j using all.vars(), for symbol := expr, it includes both symbol, := and all symbols in expr. Whenever there's no symbol on lhs of :=, there won't be such problem, e.g.
# no symbol on lhs of `:=` but a call to create a character vectordt[, c("z", "w") :=list(ncol(.SD), get("y")), .SDcols="x"]
It looks like we should specially handle := expressions in j when determining the variables to include in .SD.
When I use
:=
together with.SD
,.SDcols
andget()
, for example,The first time is ok, but whenever
z
already exists, the code above will produce incorrect results since.SD
includes bothx
andz
, which should bex
only, as restricted by.SDcols
.The following code is a minimal example and demonstrates the problem:
The output looks like
The text was updated successfully, but these errors were encountered: