Here is a function
f <- function(orderData){
colNames <- paste0(\"lim_\",sort(unique(orderData[,XLM])))
orderData[, (colNames):={lim_=f
In both cases the length of the data table is 2 and the truelength is 100:
> length(dt); truelength(dt)
[1] 2
[1] 100
> length(dt1); truelength(dt1)
[1] 2
[1] 100
however, in the case of dt
colNames
is 300 so 2+300 exceeds the truelength but in the case of dt1
colNames
is 81 so 2+81 does not.
You can either allocate a larger truelength in advance, e.g.
alloc.col(dt, 1000)
or you can set the default so that all data tables have a larger default:
options(datatable.alloccol = 1000)
See ?alloc.col
,