<div dir="ltr">My mistake, you're correct. I reversed it in my head.</div><div class="gmail_extra"><br clear="all"><div><div dir="ltr">-------<br>Nathaniel Graham<br><a href="mailto:npgraham1@gmail.com" target="_blank">npgraham1@gmail.com</a><br>
<a href="mailto:npgraham1@uky.edu" target="_blank">npgraham1@uky.edu</a><div><a href="https://sites.google.com/site/npgraham1/" target="_blank">https://sites.google.com/site/npgraham1/</a><br></div></div></div>
<br><br><div class="gmail_quote">On Tue, May 20, 2014 at 8:50 PM, Gabor Grothendieck <span dir="ltr"><<a href="mailto:ggrothendieck@gmail.com" target="_blank">ggrothendieck@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="">On Tue, May 20, 2014 at 8:45 PM, Nathaniel Graham <<a href="mailto:npgraham1@gmail.com">npgraham1@gmail.com</a>> wrote:<br>
> Thanks! That's a good idea, and a lot simpler than what I was concocting in<br>
> my head. I'll give that a try. I think--just for for posterity--you mean<br>
><br>
> DT[, importance := 0 - <a href="http://is.na" target="_blank">is.na</a>(V3)]<br>
><br>
> rather than 0 + <a href="http://is.na" target="_blank">is.na</a>(V3), so that rows with V3 are lower than rows without.<br>
<br>
</div>0 + <a href="http://is.na" target="_blank">is.na</a>(V3) was intended. We want the good rows to have a lower<br>
importance than the bad rows so 0+<a href="http://is.na" target="_blank">is.na</a>(V3) gives a non-NA V3 an<br>
importance of 0 and it gives a V3 which is NA an importance of 1.<br>
When we sort them using setkey the non-NA of 0 comes first so it is<br>
the one picked by unique.<br>
<div class=""><br>
> DT[, importance := 0+<a href="http://is.na" target="_blank">is.na</a>(V3)]<br>
> setkey(DT, V1, V2, importance)<br>
> unique(DT, by = c("V1", "V2"))<br>
</div> V1 V2 V3 importance<br>
1: 1 3 TRUE 0<br>
2: 1 4 TRUE 0<br>
3: 2 3 TRUE 0<br>
4: 2 4 TRUE 0<br>
5: 3 1 NA 1<br>
</blockquote></div><br></div>