Submitted by: Chong Wang; Assigned to: Nobody; R-Forge link
when the data.table DT is saved to an environment and then reloaded, adding new columns doesn't have effect on the data.table. (see data.table B)
require(data.table)
env <- new.env(parent = emptyenv())
DT <- data.table(x = 1:3)
assign("DT", DT, envir=env)
env$DT[, y := 3]
A <- copy(env$DT)
save(env, file="temp.rda")
rm (DT)
rm (env)
load("temp.rda")
env$DT[, z:=10]
B <- copy(env$DT)
env$DT <- copy(env$DT)
env$DT[, z:=10]
C <- copy(env$DT)
Now, looking at the data.tables A, B and C:
A
# x y
#1: 1 3
#2: 2 3
B
# x y
#1: 1 3
#2: 2 3
C
# x y z
#1: 1 3 10
#2: 2 3 10
In principal, B should have the same content as C.
Thanks!
Submitted by: Chong Wang; Assigned to: Nobody; R-Forge link
when the data.table
DTis saved to an environment and then reloaded, adding new columns doesn't have effect on the data.table. (see data.tableB)Now, looking at the data.tables
A,BandC:In principal,
Bshould have the same content asC.Thanks!