Skip to content

data.table allocates over alloc.col limit with [,:= but not set() #1831

Description

@zachokeeffe

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

Activity

  1. tyner commented on Dec 10, 2019

    @tyner

    When you say "does not work", what is the actual error message?

  2. added this to the 1.18.2 milestone on Jan 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions