Wednesday, 28 August 2013

data.table doesn't modify by reference if the object is freshly loaded from file?

data.table doesn't modify by reference if the object is freshly loaded
from file?

It seems that if a data.table is freshly loaded, a function containing :=
wouldn't modify by reference.
Can anyone reproduce it? Is it a bug?
test<-function(data){data[,ppp:=1]}
a<-data.table(x=1:2)
save(a,file="ttt")
load("ttt")
test(a) # show ppp
a # doesn't have ppp
b<-data.table(x=1:2)
test(b) # show ppp
b # has ppp

No comments:

Post a Comment