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

Matthew Dowle mdowle at mdowle.plus.com
Mon Jun 10 10:52:41 CEST 2013


 

Hi, 

How about ~ instead of ! ? I ruled out - previously to leave +
and - available for future use. NJ() may be possible too. 

Matthew 

On
10.06.2013 09:35, Arunkumar Srinivasan wrote: 

> Hi Matthew, 
> My view
(from the last reply) more or less reflects mnel's comments here:
http://stackoverflow.com/questions/16239153/dtx-and-dtx-treat-na-in-x-inconsistently#comment23317096_16240143

> 
> Pasted here for convenience: 
> data.table is mimicing subset in
its handling of NA values in logical i arguments. -- the only issue is
the ! prefix signifying a not-join, not the way one might expect.
Perhaps the not join prefix could have been NJ not ! to avoid this
confusion -- this might be another discussion to have on the mailing
list -- (I think it is a discussion worth having) 
> 
> Arun 
> 
> On
Monday, June 10, 2013 at 10:28 AM, Arunkumar Srinivasan wrote: 
> 
>>>
Hm, good point. Is data.table consistent with SQL already, for both ==
and !=, and so no change needed?
>> 
>> Yes, I believe it's already
consistent with SQL. However, the current interpretation of NA
(documentation) being treated as FALSE is not needed / untrue, imho
(Please see below). 
>> 
>>> And it was correct for Frank to be
mistaken.
>> 
>> Yes, it seems like he was mistaken. 
>> 
>> Maybe just
some more doc
>> 
>>> cumentation reflects the role of subsetting in
data.table mimicking "subset" function
>> be in line with SQL) by
dropping NA evaluated logicals. From a couple of posts before, where I
pasted the code where NAs are replaced to FALSE were not necessary as
`irows <- which(i)` makes clear that `which` is being used to get
indices and then subset, this fits perfectly well with the
interpretation of NA in data.table. 
>> 
>> Are you happy that
DT[!(x==.)] and DT[x!=.] do treat NA inconsistently? :

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


More information about the datatable-help mailing list