<div dir="ltr">Amazing!! Thanks Steve, that's gonna come very much in handy<div>-Rick</div><div class="gmail_extra"><br>
<br><br><div class="gmail_quote">On Thu, Aug 1, 2013 at 12:58 PM, Steve Lianoglou <span dir="ltr"><<a href="mailto:lianoglou.steve@gene.com" target="_blank">lianoglou.steve@gene.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<div class="im"><br>
On Thu, Aug 1, 2013 at 12:27 AM, Arunkumar Srinivasan<br>
<<a href="mailto:aragorn168b@gmail.com">aragorn168b@gmail.com</a>> wrote:<br>
> Steve,<br>
><br>
> Yes, exactly. If you dint have to subset the data.table as in your example,<br>
<br>
</div>Not sure what subsetting (or not) has to do with it, but ...<br>
<div class="im"><br>
> the equivalent operation would be to set the key of DT1 to NULL and then<br>
> doing `unique` and storing it in DT2 and then setting the key back to "A" on<br>
> DT1.<br>
><br>
> And it'd be nice to be able to do: `unique(DT1, usekey=FALSE)` or something<br>
> like that so that we don't have to NULL and set the key of DT1.<br>
<br>
</div>Ask and you shall receive :-)<br>
<br>
I added a `use.key=TRUE` parameter to unique.data.table and<br>
duplicated.data.table which is in SVN revision 888. This runs the<br>
relevant functions on the data.table as if it were not keyed at all.<br>
<div class="im"><br>
R> DT1 <- CJ(A=0:1,B=1:6,D0=0:1,D=0:1)[D>=D0]<br>
R> setkey(DT1,A)<br>
R> DT2 <- unique.data.frame(DT1[,-which(names(DT1)%in%'B'),with=FALSE])<br>
</div>R> dt2 <- unique(DT1[,-which(names(DT1) %in% 'B'),with=FALSE], use.key=FALSE)<br>
R> all.equal(DT2, dt2, check.attributes=FALSE)<br>
[1] TRUE<br>
<br>
The all.equal test will fail when check.attributers is TRUE because<br>
dt2 is still keyed by 'A'.<br>
<br>
R> key(DT1)<br>
[1] "A"<br>
<br>
R> key(DT2)<br>
NULL<br>
<br>
R> key(dt2)<br>
[1] "A"<br>
<br>
Hope that covers it,<br>
<div class="im HOEnZb">-steve<br>
<br>
--<br>
Steve Lianoglou<br>
Computational Biologist<br>
Bioinformatics and Computational Biology<br>
Genentech<br>
</div><div class="HOEnZb"><div class="h5">_______________________________________________<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>
</div></div></blockquote></div><br></div></div>