-
Notifications
You must be signed in to change notification settings - Fork 986
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
Incorrect setkey result #3766
Comments
I think the problem is
So when sorting happens, it sorts So this works:
I'm not sure if this is expected behavior, or a bug in |
Therefore I think it's actually the same root issue as the one you referenced, #3496: |
Yes, this makes sense. The only thing I can't understand is why the code without filtration works:
Probably the essence of the bug is in |
OK I've found why the code without filtration works: https://github.com/Rdatatable/data.table/blob/master/R/data.table.R#L1271-L1282
If @mattdowle or @arunsrinivasan maybe you could help to understand why this check is not done the I see a few referenced issues and comments: |
The column deep-copy / shallow-copy behavior does seem inconsistent... @MichaelChirico Do you think it's a bug or a desired? library(data.table)
x <- data.table(col1 = 1:5, col2 = 1:5)
v <- x[col1 %in% c(1:5), .(A = col2, B = col2)]
identical(address(v$A), address(v$B))
#> [1] TRUE
v <- x[1, .(A = col2, B = col2)]
identical(address(v$A), address(v$B))
#> [1] TRUE
v <- x[TRUE, .(A = col2, B = col2)]
identical(address(v$A), address(v$B))
#> [1] FALSE
v <- x[, .(A = col2, B = col2)]
identical(address(v$A), address(v$B))
#> [1] FALSE Created on 2019-08-16 by the reprex package (v0.2.1) |
I'm not sure; see #3768. Based on that I'm only surprised by the 3rd example. I guess |
Hello!
Minimal reproducible example:
After setting a key the order of "b" and "b2" columns is incorrect.
There are 3 "workarounds" which help to keep "y" data.table consistent:
But still the described behavior seems to be a bug.
This issue could be related to #3496
Output of sessionInfo():
The text was updated successfully, but these errors were encountered: