Skip to content

[R-Forge #5607] can not add new columns when the data.table is loaded from saved environment.  #479

@arunsrinivasan

Description

@arunsrinivasan

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!

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions