Problem
According to the "Programming on data.table" vignette:
Starting from version 1.14.2, data.table provides a robust mechanism for parameterizing expressions passed to the i, j, and by (or keyby) arguments of [.data.table. It is built upon the base R substitute function, and mimics its interface. Here, we introduce substitute2 as a more robust and more user-friendly version of base R’s substitute.
However, on installation substitute2 is unavailable and using the env argument in [.data.table errors.
Am I losing my mind, I swear this worked before?
Reprex
remove.packages("data.table")
install.packages("data.table", type="source")
library(data.table)
# data.table 1.14.2 using 6 threads (see ?getDTthreads). Latest news: r-datatable.com
?substitute2
# No documentation for ‘substitute2’ in specified packages and libraries:
# you could try ‘??substitute2’
data.table::substitute2
# Error: 'substitute2' is not an exported object from 'namespace:data.table'
dt <- data.table(a=letters[1:5], b=rnorm(5))
dt[, col, env=list(col="b")]
# Error in `[.data.table`(dt, , col, env = list(col = "b")) :
# unused argument (env = list(col = "b"))
sessionInfo
R Under development (unstable) (2021-12-19 r81394)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.4 LTS
Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so
locale:
[1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8
[4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8
[7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.14.2
loaded via a namespace (and not attached):
[1] compiler_4.2.0
Problem
According to the "Programming on data.table" vignette:
However, on installation
substitute2is unavailable and using theenvargument in[.data.tableerrors.Am I losing my mind, I swear this worked before?
Reprex
sessionInfo