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 upkeyby= may use the wrong index #3498
Comments
|
Great find. |
|
Thanks. I get the point by looking at the testing code of 1942.7... |
|
Thanks @mattdowle for the quick fix. It works great. |
The
keybymay use the wrong index if the keyby column name is the leading part of the index column name. For example, the index isCLASS_L3whilekeybyisCLASS.After a shallow investigation, I suspect the below line is the cause of this bug. I don't understand the reason of using
substring()at all. It seems not necessary. @mattdowle Any ideas?data.table/R/data.table.R
Line 867 in 426b71d
I will be happy to file a PR with tests if there's no particular reason to compare to a subset of the indices.
Thanks.
The reproducible example
(Note, although the below example is running under R3.4.4, they are reproducible on R3.5.3 as well.)
See after set up the indices, the
keybyexpression returns wrong results. In comparison, usingbystill returns correct results.Created on 2019-04-10 by the reprex package (v0.2.1)
Session info