-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Milestone
Description
When attempting to add one past whatever the limit set by alloc.col is, set() fails, but [,:= works. Once you use [,:=, set() again works. Minimal reproducible example:
library(data.table)
# make one-column test DT
DT<-data.table(V1=1:10)
# make 99 more columns with set()
for(x in 2:100){
set(DT,NULL,paste0("V",x),1:10)
}
# make 101st column with set
set(DT,NULL,"V101",1:10) # does not work
# make 101st column with [,:=
DT[,V101:=1:10] # works
# using set vs. [,:= to make the first 99
# columns does not matter:
# make one-column test DT
DT<-data.table(V1=1:10)
# make 99 more columns with [,:=]
DT[,(paste0("V",2:100)):=1:10]
# make 101st column with set
set(DT,NULL,"V101",1:10) # does not work
# make 101st column with [,:=
DT[,V101:=1:10] # works
# order does not matter:
# make one-column test DT
DT<-data.table(V1=1:10)
# make 99 more columns with [,:=]
DT[,(paste0("V",2:100)):=1:10]
# make 101st column with [,:=
DT[,V101:=1:10] # works
# but, once having used [,:= one can
# again use set():
# make 102nd column with set
set(DT,NULL,"V102",1:10) # works