Using latest development version of data.table (1.10.5): This returns an error: ``` library(data.table) testDT <- data.table(col1 = c(1,1,1, 2,2,2), col2 = c(2,2,2,1,1,1), ID = c(rep(1,3), rep(2,3))) setkeyv(testDT, "ID") testDT[, lapply(.SD, var), by = ID] ``` `Error in gvar(col1) : negative length vectors are not allowed` This however works fine: ``` testDT[, lapply(.SD, stats::var), by = ID] ID col1 col2 1: 1 0 0 2: 2 0 0 ```
Using latest development version of data.table (1.10.5):
This returns an error:
Error in gvar(col1) : negative length vectors are not allowedThis however works fine: