[datatable-help] NA's & Inconsistent behavior
Ricardo Saporta
saporta at scarletmail.rutgers.edu
Sun Jul 7 02:55:26 CEST 2013
This is regarding:
http://stackoverflow.com/questions/17508127/na-in-i-expression-of-data-table-possible-bug
x = data.table(a=c(NA, 1:3, NA))
As @flodel points out in the comments
x[as.logical(a)] and x[!!as.logical(a)]
do not return the same value
I think this can be fixed rather simply by modifying one line in
`[.data.table`, but confirmation would be helpful:
notjoin = FALSE
if (!missing(i)) {
isub = substitute(i)
.
.
.
if (is.logical(i)) {
if (identical(i, NA))
i = NA_integer_
else i[is.na(i)] = FALSE <~~~ = FALSE || notjoin
}
.
.
}
If that last copied line is changed
from: else i[is.na(i)] = FALSE
to : else i[is.na(i)] = FALSE || notjoin
I believe this would resolve the issue.
The question is, would it introduce any other issues? Are there other
corner cases we might be overlooking.
Cheers
Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20130706/e884b0c5/attachment.html>
More information about the datatable-help
mailing list