<div dir="ltr">Hi<div>I'm not sure if this was intentional and maybe not what you're asking, but the problem is caused by the string CIK being called the same as the variable CIK. Somehow in the first example "CIK" is understood as the string and in the second as the variable. Thus in the second example you're asking if the variable CIK == the variable CIK. If you change CIK to CIK2 everything works as expected:</div><div><br></div><div><font color="#000000" face="arial, sans-serif">CIK2 = "0000839087"</font></div><div><font color="#000000" face="arial, sans-serif">DT[CIK == (CIK2)][FileDate <= 10104]</font></div><div><font color="#000000" face="arial, sans-serif"><br></font></div><div><font color="#000000" face="arial, sans-serif"> CIK FileDate</font></div><div><font color="#000000" face="arial, sans-serif">1: 0000839087 10081</font></div><div><br></div><div>DT[CIK == (CIK2)&FileDate <= 10104]<br></div><div><div><br></div><div> CIK FileDate</div><div>1: 0000839087 10081</div></div><div><br></div><div>I guess someone else has to explain why data.table understands CIK and CIK differently.</div><div><br></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature">Øyvind</div></div>
<br><div class="gmail_quote">On Fri, Nov 7, 2014 at 9:51 AM, Michael Smith <span dir="ltr"><<a href="mailto:my.r.help@gmail.com" target="_blank">my.r.help@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Shouldn't the last two commands below yield identical results?<br>
<br>
DT <-<br>
data.table(<br>
CIK = c("0000060512", "0000839087"),<br>
FileDate = c(8680, 10081))<br>
CIK = "0000839087"<br>
DT[CIK == (CIK)][FileDate <= 10104]<br>
<br>
CIK FileDate<br>
1: 0000839087 10081<br>
<br>
DT[CIK == (CIK) & FileDate <= 10104]<br>
<br>
CIK FileDate<br>
1: 0000060512 8680<br>
2: 0000839087 10081<br>
_______________________________________________<br>
datatable-help mailing list<br>
<a href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a><br>
</blockquote></div><br></div></div>