When I run the following code using the package 'data.table' it appears that dt
and dt1
are linked. Both of the tables now have the new Calc
variable in it even though I only defined it in dt1
.. What is going on here please?
library(data.table)
dt <- data.table(Var1 = c(1,2,3), Var2 = c(4,5,6))
dt1 <- dt
dt1[, Calc := Var1 + Var2]