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
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help

Reply via email to