By design. See ?":=" and ?copy. If table1 is 20GB in RAM, you need to be explicit to tell data.table you really really want to copy it; i.e., table2=copy(table1).
It deliberately breaks standard R practice. Which is partly why it's a new operator that works differently. http://stackoverflow.com/questions/10225098/understanding-exactly-when-a-data-table-is-a-reference-to-vs-a-copy-of-another > 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 > [email protected] > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help > _______________________________________________ datatable-help mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
