[datatable-help] unique.data.frame should create a copy, right?

Frank Erickson FErickson at psu.edu
Wed Jul 31 00:07:45 CEST 2013


I expect DT2 <- unique.data.frame(DT1) to be a new object, but get a
warning about pointers, so apparently it is not...?

A short example:

DT1 <- data.table(1)
DT2 <- unique.data.frame(DT1)
DT2[,gah:=1]


An example closer to my application, undoing a cartesian/cross join:

DT1 <- CJ(A=0:1,B=1:6,D0=0:1,D=0:1)[D>=D0]
setkey(DT1,A)
DT2 <- unique.data.frame(DT1[,-which(names(DT1)%in%'B'),with=FALSE])
DT2[,gah:=1] # warning: I should have made a copy, apparently


I'm fine with explicitly making a copy, of course, and don't really know
anything about pointers. I just thought I'd bring it up.

--Frank
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20130730/e381439a/attachment.html>


More information about the datatable-help mailing list