I came across an issue with .SDcols when using get() in the j argument. I posted about it on SO here.
dt2 = data.table(col1 = rep(LETTERS[1:3], 4),
b = rnorm(12),
a = 1:12,
neg = -1)
d.vars = c('a', 'b') # used in .SDcols
negate <- 'neg'
When the neg column is called with get() the .SD table columns are ordered as in dt2 rather than according to the order given in the .SDcols = d.vars argument:
dt2[, {neg; names(.SD)}, .SDcols=d.vars]
# [1] "a " "b"
dt2[, {get(negate); names(.SD)}, .SDcols=d.vars]
# [1] "b" "a"
In the comments Frank suggested it might be related to the mget bug #1744.
> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
> packageVersion("data.table")
[1] ‘1.9.8’
The text was updated successfully, but these errors were encountered:
TonyBonen commentedFeb 20, 2017
•
edited
I came across an issue with
.SDcols
when usingget()
in thej
argument. I posted about it on SO here.When the
neg
column is called withget()
the.SD
table columns are ordered as indt2
rather than according to the order given in the.SDcols = d.vars
argument:In the comments Frank suggested it might be related to the
mget
bug #1744.The text was updated successfully, but these errors were encountered: