Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upIncorrect setkey result #3766
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] FALSECreated 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():