-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Apparently, 1.9.6 adds double underscore (__) to auto indexes and checks existence of these double underscores when accessing data.tables. However, 1.9.4. does not do either of these things. Thus, objects saved under 1.9.4 would not be usable under 1.9.6 and would throw an error in R. The bug will affect people who created and saved (perhaps, a lot of) objects under 1.9.4 and try to use them in later versions.
Minimal example:
Under R >3.2.1 and data.table <=1.9.4 run the following
abc.temp<-data.table(a=c(1,2),b=c(3,4))
abc.temp[a%in%c(1),b:=1]
save(abc.temp, file=”WhateverFolderWhateverFile.RData”)
str(abc.temp) output is:
Classes ‘data.table’ and 'data.frame': 2 obs. of 2 variables:
$ a: num 1 2
$ b: num 1 4
- attr(*, ".internal.selfref")=
- attr(, "index")= atomic
..- attr(, "a")= int
Under R>=3.2.1 and data.table 1.9.6 open the file and try to use the object
load(”WhateverFolderWhateverFile.RData”, verbose=TRUE)
abc.temp[,c:=5]
R throws error
Error in [.data.table
(abc.temp, , :=
(c, 5)) :
Internal error: __ not found in index name
The same code under data.table 1.9.6 gives auto index with underscore
abc.temp<-data.table(a=c(1,2),b=c(3,4))
abc.temp[a%in%c(1),b:=1]
str(abc.temp) output is
Classes ‘data.table’ and 'data.frame': 2 obs. of 2 variables:
$ a: num 1 2
$ b: num 1 4
- attr(*, ".internal.selfref")=
- attr(, "index")= atomic
..- attr(, "__a")= int
- attr(, "index")= atomic