Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get() reorders .SD columns #2036

TonyBonen opened this issue Feb 20, 2017 · 1 comment · Fixed by #3771

get() reorders .SD columns #2036

TonyBonen opened this issue Feb 20, 2017 · 1 comment · Fixed by #3771


Copy link

TonyBonen commented Feb 20, 2017

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’
Copy link

DavidArenburg commented Mar 1, 2017

As a side note, it is better to test bugs on the latest version (just in case they were already fixed).

@mattdowle mattdowle added this to the 1.12.4 milestone Aug 28, 2019
@jangorecki jangorecki added the programming label Apr 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging a pull request may close this issue.

4 participants