[datatable-help] Follow-up on subsetting data.table with NAs
Matthew Dowle
mdowle at mdowle.plus.com
Mon Jun 10 11:04:12 CEST 2013
On 10.06.2013 09:53, Arunkumar Srinivasan wrote:
> 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 10
> Not the
correct result! If `!(x==.)` is equal to `x != .`, then the correct
result should be the first row, isn't it?
That result makes perfect
sense to me. I don't think of !(x==.) being the same as x!=. ! is simply
a prefix. It's all the rows that aren't returned if the ! prefix wasn't
there.
> 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
That needs to be
fixed. But we're getting quite theoretical here and far away from common
use cases. Why would we ever have row numbers of the table, as a column
of the table itself and want to select the rows by number not mentioned
in that column?
It ends up in an error because `NA` is not
removed/replaced.
Links:
------
[1]
http://stackoverflow.com/questions/16239153/dtx-and-dtx-treat-na-in-x-inconsistently#comment23317096_16240143
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20130610/ff71f70d/attachment-0001.html>
More information about the datatable-help
mailing list