<div>
Hi Rick,
</div><div><br></div><div>That post is very much related to this discussion:</div><div><a href="http://lists.r-forge.r-project.org/pipermail/datatable-help/2013-June/001856.html">http://lists.r-forge.r-project.org/pipermail/datatable-help/2013-June/001856.html</a></div><div><br></div><div>I've also linked the same post to that thread.</div>
<div><div><br></div><div>Arun</div><div><br></div></div>
<p style="color: #A0A0A8;">On Sunday, July 7, 2013 at 2:55 AM, Ricardo Saporta wrote:</p>
<blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
<span><div><div><div dir="ltr"><div style="">This is regarding: </div><a href="http://stackoverflow.com/questions/17508127/na-in-i-expression-of-data-table-possible-bug">http://stackoverflow.com/questions/17508127/na-in-i-expression-of-data-table-possible-bug</a><div>
<br></div><div><pre style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px;line-height:16.666667938232422px"><code style="margin:0px;padding:0px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif"><span style="color:rgb(0,0,0);margin:0px;padding:0px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:transparent">x </span><span style="color:rgb(0,0,0);margin:0px;padding:0px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:transparent">=</span><span style="color:rgb(0,0,0);margin:0px;padding:0px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:transparent"> data</span><span style="color:rgb(0,0,0);margin:0px;padding:0px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:transparent">.</span><span style="color:rgb(0,0,0);margin:0px;padding:0px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:transparent">table</span><span style="color:rgb(0,0,0);margin:0px;padding:0px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:transparent">(</span><span style="color:rgb(0,0,0);margin:0px;padding:0px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:transparent">a</span><span style="color:rgb(0,0,0);margin:0px;padding:0px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:transparent">=</span><span style="color:rgb(0,0,0);margin:0px;padding:0px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:transparent">c</span><span style="color:rgb(0,0,0);margin:0px;padding:0px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:transparent">(</span><span style="color:rgb(0,0,0);margin:0px;padding:0px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:transparent">NA</span><span style="color:rgb(0,0,0);margin:0px;padding:0px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:transparent">,</span><span style="color:rgb(0,0,0);margin:0px;padding:0px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:transparent"> </span><span style="color:rgb(128,0,0);margin:0px;padding:0px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:transparent">1</span><span style="margin:0px;padding:0px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:transparent"><font color="#000000">:</font><font color="#800000">3</font></span><span style="color:rgb(0,0,0);margin:0px;padding:0px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:transparent">,</span><span style="color:rgb(0,0,0);margin:0px;padding:0px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:transparent"> NA</span><span style="color:rgb(0,0,0);margin:0px;padding:0px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:transparent">))</span></code></pre>
</div><div style="">As @flodel points out in the comments </div><div style=""><code style="margin:0px;padding:1px 5px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;color:rgb(68,68,68);line-height:17.77777862548828px">x[as.logical(a)]</code><span style="color:rgb(68,68,68);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-size:13.333333969116211px;line-height:17.77777862548828px"> and </span><code style="margin:0px;padding:1px 5px;border:0px;font-size:13.333333969116211px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;color:rgb(68,68,68);line-height:17.77777862548828px">x[!!as.logical(a)]</code><br>
</div><div style="">do not return the same value</div><div style=""><br></div><div style="">I think this can be fixed rather simply by modifying one line in `[.data.table`, but confirmation would be helpful: </div><div style=""><br></div>
<div style=""><div> notjoin = FALSE</div><div> if (!missing(i)) {</div><div> isub = substitute(i)</div><div> .</div><div> .</div><div> .</div><div> if (is.logical(i)) {<br></div><div>
if (identical(i, NA)) </div><div> i = NA_integer_</div><div> else i[<a href="http://is.na">is.na</a>(i)] = FALSE <~~~ = FALSE || notjoin</div><div> }</div><div><div> .</div>
</div><div><div> .</div></div><div> }</div></div><div><br></div><div style="">If that last copied line is changed </div><div style=""> from: else i[<a href="http://is.na">is.na</a>(i)] = FALSE</div><div style=""> to : else i[<a href="http://is.na">is.na</a>(i)] = FALSE || notjoin</div>
<div style="">I believe this would resolve the issue. </div><div style=""><br></div><div style="">The question is, would it introduce any other issues? Are there other corner cases we might be overlooking. </div><div style=""><br></div>
<div style="">Cheers </div><div style="">Rick<br></div><div style=""><br></div><div><br></div></div>
</div><div><div>_______________________________________________</div><div>datatable-help mailing list</div><div><a href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a></div><div><a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a></div></div></div></span>
</blockquote>
<div>
<br>
</div>