It seems to be a bug introduced post 1.8.10 related to setkey with DT which contains lists. Run two below codes to see the issue:
library(data.table)
dtl <- list()
dtl[[1]] <- data.table(scenario = 1,
processing = c(function(x) x))
dtl[[2]] <- data.table(scenario = 2,
processing = c(function(x) x))
dt <- rbindlist(dtl)
setkeyv(dt, c("scenario"))
and second below, currently produce error:
dtl <- list()
dtl[[1]] <- data.table(scenario = 2, # <- note we change order
processing = c(function(x) x))
dtl[[2]] <- data.table(scenario = 1,
processing = c(function(x) x))
dt <- rbindlist(dtl)
setkeyv(dt, c("scenario")) #setkey cannot sort?
It was working well in 1.8.10. I'm not able to setkey on my DT, seems to be related to DT which contains list of functions. Any easy workaround? I track the error msg to C code but have no idea how to fix it.
R 3.0.2 + data.table 1.9.2 on windows 64bit Thanks
setkey
doesn't allow list columns as keys. However, a bug insetkey
did not allow setting key ondata.table
just containing list columns. This is now fixed. Closes #5366. Thanks to James Sams for reporting and to Michael Nelson for pinpointing the issue with a minimal reproducible example. Also thanks to MusX for reporting on SO.
We should be pushing 1.9.4 (next stable release) to CRAN sometime soon.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With