-
Notifications
You must be signed in to change notification settings - Fork 991
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
data.table not recognising logical in i #1479
Comments
I had the same issue. I am using 1.9.6 of data.table on CRAN. This is a really terrifying bug. |
Your example is way too baroque for me to guess where the bug starts, but as a workaround...
There's also |
Do you know why this issue would show up? timetable[CURRENT_TRIP == F, ] would only return partial records, but timetable[CURRENT_TRIP == 0, ] would work (CURRENT_TRIP column, as the example here, is a logical column). Thanks. |
This is a minimal example require(data.table) #v1.9.6
dt <- data.table(a = rep(c(F,F,T,F,F,F,F,F,F), 3),
b = c("x", "y", "z"))
set2key(dt, a)
dt[, a := as.logical(sum(a)), by = b]
dt[a == T, .N] # 7
sum(dt$a == T) # 9 It seems like the secondary key is not updated when the key2 column is altered by a primitive function in j and by is used. |
Thanks @ChristK for the nice MRE. Fixed now. |
From here: http://stackoverflow.com/questions/34433063/data-table-not-recognising-logical-in-filter
In the following snippet, data.table does not seem to recognize logicals when used in i.
All my attempts to reproduce the problem in a minimal example failed, that's why I am posting the complete section here (sorry for that). Glad for comments to make the example "minimal".
When using the filter CURRENT_TRIP == T not all rows (but only 8 rows) containing the value "TRUE" are recognized. When using alternative solutions, all 15 rows can be identified.
Secondary issue:
Why does adding an additional bracket solve the problem?
"nrow(timetable[(CURRENT_TRIP == T)]) #15"
The text was updated successfully, but these errors were encountered: