[datatable-help] Follow-up on subsetting data.table with NAs

Arunkumar Srinivasan aragorn168b at gmail.com
Mon Jun 10 10:55:52 CEST 2013


(Sorry @Matthew for the double email, I forgot to include the list once again).

However, one inconsistency I find with the use of `!(x==.)` is this:

dt1 <- data.table(x = 0:4, y=5:9)
> dt1[!(x)]
   x  y
1: 4 9


Not the correct result! If `!(x==.)` is equal to `x != .`, then the correct result should be the first row, isn't it?

dt2 <- data.table(x = c(0,3,4,NA), y = c(NA,4,5,NA))
> dt2[!(x)] # ends up in an error
Error in seq_len(nrow(x))[-irows] : 
  only 0's may be mixed with negative subscripts


It ends up in an error because `NA` is not removed/replaced.

Running the same on data.frame gives the results it's supposed to.

Arun

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


More information about the datatable-help mailing list