[datatable-help] data.table BUG : data.table assignment

Christoph Jäckel christoph.jaeckel at wi.tum.de
Thu Oct 4 14:07:19 CEST 2012


This is actually intended behaviour and I had the problem once as well.
Here is my question and the solution to it:

http://stackoverflow.com/questions/8030452/pass-by-reference-the-operator-in-the-data-table-package

In a nutshell: Use copy() if you don't want table2 to have y as well.

I hope this helps,

Christoph

On Thu, Oct 4, 2012 at 1:56 PM, natus <niparisco at gmail.com> wrote:

> Hello,
>
> see this example :
>
> require(data.table)
>
> table1<-data.table(id=c(1,2,3),x=c(1,2,3))
> table2<-table1
> table1[,y:=sum(x)]
> table1
> table2
>
> The problem ? Both of table1 and table2 have the variable 'y' BUT only
> table1 should.
>
> Thx
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/data-table-BUG-data-table-assignment-tp4644988.html
> Sent from the datatable-help mailing list archive at Nabble.com.
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20121004/f82a0b9e/attachment.html>


More information about the datatable-help mailing list