-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Description
# Minimal reproducible example
On the current R-devel, the following code
library(data.table)
dt <- data.table(a=1:4,b=c(1,2,1,2))
dt[,yes:=.N,by=b, verbose = TRUE]
Throws the follows the following error
Detected that j uses these columns: <none>
Finding groups using forderv ... forderReuseSorting: opt not possible: is.data.table(DT)=0, sortGroups=0, all1(ascArg)=1
forder.c received 4 rows and 1 columns
forderReuseSorting: opt=0, took 0.000s
0.000s elapsed (0.000s cpu)
Finding group sizes from the positions (can be avoided to save RAM) ... 0.000s elapsed (0.000s cpu)
Getting back original order ... forderReuseSorting: opt not possible: is.data.table(DT)=0, sortGroups=1, all1(ascArg)=1
forder.c received a vector type 'integer' length 2
forderReuseSorting: opt=0, took 0.000s
0.000s elapsed (0.000s cpu)
lapply optimization is on, j unchanged as '.N'
Making each group and running j (GForce FALSE) ...
Error in `[.data.table`(dt, , `:=`(yes, .N), by = b, verbose = TRUE) :
attempt access index 2/2 in VECTOR_ELT
This should be perfectly valid data.table code, right?
I get the same error both on 1.17.8 and 1.17.99 versions of data.table. The code runs without error on R-release and older.
I did not find any links to this issue when searching. Are you the data.table developers aware of this issue and working on it? Or do you know whether this is a temporary thing on R-devel?
I am about submit my package to CRAN and I am unsure how to handle this. Any input, or guidance on this would be highly appreciated.
# Output of sessionInfo()
R Under development (unstable) (2025-12-18 r89199 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26100)
Matrix products: default
LAPACK version 3.12.1
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8 LC_NUMERIC=C LC_TIME=English_United States.utf8
time zone: Europe/Oslo
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.17.99
loaded via a namespace (and not attached):
[1] compiler_4.6.0 magrittr_2.0.3 R6_2.6.1 cli_3.6.5 tools_4.6.0 rstudioapi_0.17.1 brio_1.1.5 testthat_3.2.3 rlang_1.1.6