Steve, Yes, exactly. If you dint have to subset the data.table as in your example, the equivalent operation would be to set the key of DT1 to NULL and then doing `unique` and storing it in DT2 and then setting the key back to "A" on DT1.
And it'd be nice to be able to do: `unique(DT1, usekey=FALSE)` or something like that so that we don't have to NULL and set the key of DT1. Arun On Wednesday, July 31, 2013 at 8:02 PM, Steve Lianoglou wrote: > Hi all, > > On Wed, Jul 31, 2013 at 9:09 AM, Arunkumar Srinivasan > <[email protected] (mailto:[email protected])> wrote: > > Ricardo, > > > > You read my mind.. :) I was thinking of the same as well.. Whether the > > community agrees or not would be interesting as well. It could save trouble > > with "alloc.col" manually. > > > > > It's easy enough to add -- just to be sure, the behavior required from > the OP would be equivalent to calling unique on a data.table that has > no key, right? For example, instead of this: > > R> DT1 <- CJ(A=0:1,B=1:6,D0=0:1,D=0:1)[D>=D0] > R> setkey(DT1,A) > R> DT2 <- unique.data.frame(DT1[,-which(names(DT1)%in%'B'),with=FALSE]) > R> DT2[,gah:=1] # warning: I should have made a copy, apparently > > You could just do: > > R> DT1 <- CJ(A=0:1,B=1:6,D0=0:1,D=0:1)[D>=D0] > R> DT2 <- unique(DT1[, -which(names(DT1)%in%'B'), with=FALSE]) > R> DT2[,gah:=1] > > Right? > > -steve > > -- > Steve Lianoglou > Computational Biologist > Bioinformatics and Computational Biology > Genentech > >
_______________________________________________ datatable-help mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
