diff --git a/NAMESPACE b/NAMESPACE index 5c4f509e1..829dc0800 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -27,7 +27,9 @@ export(tstrsplit) export(frank) export(frankv) export(address) -export(.SD,.N,.I,.GRP,.NGRP,.BY,.EACHI, ., J, measure, patterns) +export(.SD,.N,.I,.GRP,.NGRP,.BY,.EACHI, measure, patterns) +# TODO(#6197): Export these. +# export(., J) export(rleid) export(rleidv) export(rowid) diff --git a/NEWS.md b/NEWS.md index 24f2bfe33..6af185da4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -100,7 +100,10 @@ 16. `print.data.table` gains new argument `show.indices` and option `datatable.show.indices` that allows the user to print a `data.table`'s indices as columns without having to modify the `data.table` itself. Thanks @MichaelChirico for the report and @joshhwuu for the PR. -17. `.`, `J`, `measure`, and `patterns` are now exported for use within `[` and `melt()`, for consistency with other NSE exports like `.N` and `:=`, [#5604](https://github.com/Rdatatable/data.table/issues/5604). Package developers can now import these names to avoid `R CMD check` `NOTE`s about them being undefined variables. Thanks to @MichaelChirico and @ylelkes for the suggestions and @Nj221102 for implementing. +17. The `measure` and `patterns` functions are now exported for use within `[` and `melt()` to ensure consistency with other non-standard evaluation (NSE) exports like `.N` and `:=`. This change addresses [#5604](https://github.com/Rdatatable/data.table/issues/5604), allowing package developers to import these names and avoid `R CMD check` `NOTE`s about undefined variables. Thanks to @MichaelChirico and @ylelkes for their suggestions, and to @Nj221102 for the implementation. + + We plan to export similar placeholders for `.` and `J` in roughly one year (e.g. data.table 1.18.0), but excluded them from this release to avoid back-compatibility issues. Specifically, some packages doing `import(plyr)` _and_ `import(data.table)`, and/or with those packages in `Depends`, will error when data.table starts exporting `.` (and similarly for a potential conflict with `rJava::J()`). We discourage using data.table (or any package, really) in Depends; blanket `import()` of package is also generally best avoided. See `vignette("datatable-importing")`. + ## TRANSLATIONS diff --git a/R/data.table.R b/R/data.table.R index 245540911..f77e75ae6 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -2770,6 +2770,7 @@ address = function(x) .Call(Caddress, eval(substitute(x), parent.frame())) stopf('Check that is.data.table(DT) == TRUE. Otherwise, :=, `:=`(...) and let(...) are defined for use in j, once only and in particular ways. See help(":=").') } +# TODO(#6197): Export these. J = function(...) { stopf("J() called outside of [.data.table. J() is only intended for use in i.") } diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index ba6a872cc..95bcaf1c1 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -2186,7 +2186,9 @@ if (ncol(DT)==2L) setnames(DT,c("A","B")) # else don't stop under torture with s test(714, DT[,z:=6:10], data.table(A=1:5,B=5,z=6:10)) # Test J alias is now removed outside DT[...] from v1.8.7 (to resolve rJava::J conflict) -test(715, J(a=1:3,b=4), error="J() called outside of [.data.table. J() is only intended for use in i.") +test(715, J(a=1:3,b=4), error=base_messages$missing_function("J")) +# future: +# test(715, J(a=1:3,b=4), error="J() called outside of [.data.table. J() is only intended for use in i.") # Test get in j DT = data.table(a=1:3,b=4:6)