[datatable-help] NA's & Inconsistent behavior

Arunkumar Srinivasan aragorn168b at gmail.com
Sun Jul 7 12:08:14 CEST 2013


Hi Rick, 

That post is very much related to this discussion:
http://lists.r-forge.r-project.org/pipermail/datatable-help/2013-June/001856.html

I've also linked the same post to that thread. 

Arun


On Sunday, July 7, 2013 at 2:55 AM, Ricardo Saporta wrote:

> 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 (http://is.na)(i)] = FALSE  <~~~  = FALSE || notjoin
>         }
>         .
> 
>         .
> 
>     }
> 
> 
> If that last copied line is changed 
>   from:   else i[is.na (http://is.na)(i)] = FALSE
>   to    :   else i[is.na (http://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
> datatable-help at lists.r-forge.r-project.org (mailto:datatable-help at lists.r-forge.r-project.org)
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
> 
> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20130707/f433c814/attachment.html>


More information about the datatable-help mailing list