From 16683b2d268729c0712a4fc16d4542c25f3f0f25 Mon Sep 17 00:00:00 2001 From: nitish jha Date: Mon, 6 May 2024 22:27:17 +0530 Subject: [PATCH 01/24] masking function --- NAMESPACE | 2 +- R/data.table.R | 4 ++++ inst/tests/tests.Rraw | 2 +- vignettes/datatable-importing.Rmd | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index b9872ee7e..cb5f573ba 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -27,7 +27,7 @@ export(tstrsplit) export(frank) export(frankv) export(address) -export(.SD,.N,.I,.GRP,.NGRP,.BY,.EACHI) +export(.SD,.N,.I,.GRP,.NGRP,.BY,.EACHI, ., J, patterns, measure) export(rleid) export(rleidv) export(rowid) diff --git a/R/data.table.R b/R/data.table.R index 6c4ee8e62..c905efc5c 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -12,6 +12,10 @@ methods::setPackageName("data.table",.global) # (2) export() in NAMESPACE # (3) add to vignettes/datatable-importing.Rmd#globals section .SD = .N = .I = .GRP = .NGRP = .BY = .EACHI = NULL +. = function(...) NULL +J = function(...) NULL +patterns = function(...) NULL +measure = function(...) NULL # These are exported to prevent NOTEs from R CMD check, and checkUsage via compiler. # But also exporting them makes it clear (to users and other packages) that data.table uses these as symbols. # And NULL makes it clear (to the R's mask check on loading) that they're variables not functions. diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 2cc8453a3..683fb8a16 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -2181,7 +2181,7 @@ 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=base_messages$missing_function("J")) +test(715, J(a=1:3,b=4), NULL) # Test get in j DT = data.table(a=1:3,b=4:6) diff --git a/vignettes/datatable-importing.Rmd b/vignettes/datatable-importing.Rmd index f1d1e9257..2f534ef37 100644 --- a/vignettes/datatable-importing.Rmd +++ b/vignettes/datatable-importing.Rmd @@ -118,7 +118,7 @@ aggr = function (x) { } ``` -The case for `data.table`'s special symbols (`.SD`, `.BY`, `.N`, `.I`, `.GRP`, `.NGRP`, and `.EACHI`; see `?.N`) and assignment operator (`:=`) is slightly different. You should import whichever of these values you use from `data.table`'s namespace to protect against any issues arising from the unlikely scenario that we change the exported value of these in the future, e.g. if you want to use `.N`, `.I`, and `:=`, a minimal `NAMESPACE` would have: +The case for `data.table`'s special symbols (`.SD`, `.BY`, `.N`, `.I`, `.GRP`, `.NGRP`, `.`, `J`, `patterns`, `measure` and `.EACHI`; see `?.N`) and assignment operator (`:=`) is slightly different. You should import whichever of these values you use from `data.table`'s namespace to protect against any issues arising from the unlikely scenario that we change the exported value of these in the future, e.g. if you want to use `.N`, `.I`, and `:=`, a minimal `NAMESPACE` would have: ```r importFrom(data.table, .N, .I, ':=') From 0003f9a7dddfb31e79d1041dd87b84c5f40b06b0 Mon Sep 17 00:00:00 2001 From: Nitish Jha <151559388+Nj221102@users.noreply.github.com> Date: Thu, 9 May 2024 15:55:20 +0530 Subject: [PATCH 02/24] Update data.table.R --- R/data.table.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/data.table.R b/R/data.table.R index 9c4d27808..15f16d882 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -18,7 +18,7 @@ patterns = function(...) NULL measure = function(...) NULL # These are exported to prevent NOTEs from R CMD check, and checkUsage via compiler. # But also exporting them makes it clear (to users and other packages) that data.table uses these as symbols. -# And NULL makes it clear (to the R's mask check on loading) that they're variables not functions. +# The use of NULL during loading signals to R's mask check that these entities aren't defined with specific behaviors. # utils::globalVariables(c(".SD",".N")) was tried as well, but exporting seems better. # So even though .BY doesn't appear in this file, it should still be NULL here and exported because it's # defined in SDenv and can be used by users. From 86ea33c0b822323bb75b464ca9718576671ef676 Mon Sep 17 00:00:00 2001 From: nitish jha Date: Sun, 2 Jun 2024 01:12:25 +0530 Subject: [PATCH 03/24] Removed mask for pattern and measure --- NAMESPACE | 2 +- R/data.table.R | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index cb5f573ba..a6afbc185 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -27,7 +27,7 @@ export(tstrsplit) export(frank) export(frankv) export(address) -export(.SD,.N,.I,.GRP,.NGRP,.BY,.EACHI, ., J, patterns, measure) +export(.SD,.N,.I,.GRP,.NGRP,.BY,.EACHI, ., J) export(rleid) export(rleidv) export(rowid) diff --git a/R/data.table.R b/R/data.table.R index b025ff9d1..131ed2613 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -14,8 +14,6 @@ methods::setPackageName("data.table",.global) .SD = .N = .I = .GRP = .NGRP = .BY = .EACHI = NULL . = function(...) NULL J = function(...) NULL -patterns = function(...) NULL -measure = function(...) NULL # These are exported to prevent NOTEs from R CMD check, and checkUsage via compiler. # But also exporting them makes it clear (to users and other packages) that data.table uses these as symbols. # The use of NULL during loading signals to R's mask check that these entities aren't defined with specific behaviors. From e1772e6abdbd27d58ed23344067c0fd36337f63f Mon Sep 17 00:00:00 2001 From: nitish jha Date: Mon, 3 Jun 2024 09:24:41 +0530 Subject: [PATCH 04/24] exporting pattern and measure --- NAMESPACE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NAMESPACE b/NAMESPACE index a6afbc185..08061952f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -27,7 +27,7 @@ export(tstrsplit) export(frank) export(frankv) export(address) -export(.SD,.N,.I,.GRP,.NGRP,.BY,.EACHI, ., J) +export(.SD,.N,.I,.GRP,.NGRP,.BY,.EACHI, ., J, measure, patterns) export(rleid) export(rleidv) export(rowid) From a1fdd4e7a481bc318af6cdb85dc6775ace74f414 Mon Sep 17 00:00:00 2001 From: nitish jha Date: Mon, 3 Jun 2024 18:58:20 +0530 Subject: [PATCH 05/24] added news entry --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 0cb593a9b..e5e165021 100644 --- a/NEWS.md +++ b/NEWS.md @@ -96,6 +96,8 @@ 14. `setNumericRounding()` now invisibly returns the old rounding value instead of `NULL`, which is now consistent with similar behavior by `setwd()`, `options()`, etc. Thanks @MichaelChirico for the report and @joshhwuu for the fix. +15. Extended support for non-standard evaluation (NSE) constructs within `[` and `melt()` functions. Now, constructs like `.`, `J`, `measure`, and `patterns` are exported, ensuring they are consistently available. Previously, only `.N`, `.I`, `.GRP`, `.GRPI`, `.SD`, and `:=` were exported. This update helps maintain consistency and functionality across your data.table usage, [#5604](https://github.com/Rdatatable/data.table/issues/5604) and [#5277](https://github.com/Rdatatable/data.table/issues/5277). Note: `measure` and `patterns` do not need additional masking as they are defined within `fmelt.R`, while the following constructs are masked as functions: `.`, `J`, `.N`, `.I`, `.GRP`, `.GRPI`, `.SD`, and `:=`. Thanks @tdhock for suggestions and @Nj221102 for implementing this improvement. + # data.table [v1.15.0](https://github.com/Rdatatable/data.table/milestone/29) (30 Jan 2024) ## BREAKING CHANGE From bda02d834d8a114a2b39f20c5b79c5a5401d58cd Mon Sep 17 00:00:00 2001 From: nitish jha Date: Tue, 4 Jun 2024 00:40:16 +0530 Subject: [PATCH 06/24] editing news item --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index e5e165021..5da239b2c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -96,7 +96,7 @@ 14. `setNumericRounding()` now invisibly returns the old rounding value instead of `NULL`, which is now consistent with similar behavior by `setwd()`, `options()`, etc. Thanks @MichaelChirico for the report and @joshhwuu for the fix. -15. Extended support for non-standard evaluation (NSE) constructs within `[` and `melt()` functions. Now, constructs like `.`, `J`, `measure`, and `patterns` are exported, ensuring they are consistently available. Previously, only `.N`, `.I`, `.GRP`, `.GRPI`, `.SD`, and `:=` were exported. This update helps maintain consistency and functionality across your data.table usage, [#5604](https://github.com/Rdatatable/data.table/issues/5604) and [#5277](https://github.com/Rdatatable/data.table/issues/5277). Note: `measure` and `patterns` do not need additional masking as they are defined within `fmelt.R`, while the following constructs are masked as functions: `.`, `J`, `.N`, `.I`, `.GRP`, `.GRPI`, `.SD`, and `:=`. Thanks @tdhock for suggestions and @Nj221102 for implementing this improvement. +15. Extended support for non-standard evaluation (NSE) constructs within `[` and `melt()` functions. Now, constructs like `.`, `J`, `measure`, and `patterns` are exported, ensuring they are consistently available. Previously, only `.N`, `.I`, `.GRP`, `.GRPI`, `.SD`, and `:=` were exported. This update helps maintain consistency and functionality across your data.table usage, [#5604](https://github.com/Rdatatable/data.table/issues/5604) and [#5277](https://github.com/Rdatatable/data.table/issues/5277). Thanks @tdhock for suggestions and @Nj221102 for implementing this improvement. # data.table [v1.15.0](https://github.com/Rdatatable/data.table/milestone/29) (30 Jan 2024) From 82ca5388c48ca0af6eb6791bab1d07a6f8f3509b Mon Sep 17 00:00:00 2001 From: nitish jha Date: Wed, 5 Jun 2024 00:37:14 +0530 Subject: [PATCH 07/24] updating news --- NEWS.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 5da239b2c..24361691d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -96,7 +96,9 @@ 14. `setNumericRounding()` now invisibly returns the old rounding value instead of `NULL`, which is now consistent with similar behavior by `setwd()`, `options()`, etc. Thanks @MichaelChirico for the report and @joshhwuu for the fix. -15. Extended support for non-standard evaluation (NSE) constructs within `[` and `melt()` functions. Now, constructs like `.`, `J`, `measure`, and `patterns` are exported, ensuring they are consistently available. Previously, only `.N`, `.I`, `.GRP`, `.GRPI`, `.SD`, and `:=` were exported. This update helps maintain consistency and functionality across your data.table usage, [#5604](https://github.com/Rdatatable/data.table/issues/5604) and [#5277](https://github.com/Rdatatable/data.table/issues/5277). Thanks @tdhock for suggestions and @Nj221102 for implementing this improvement. +15. `.`, `J`, `measure`, and `patterns` are now exported to support non-standard evaluation (NSE) constructs within `[` and `melt()` functions. Previously, only `.N`, `.I`, `.GRP`, `.GRPI`, `.SD`, and `:=` were exported. This update ensures that these constructs are consistently available, maintaining consistency and functionality across your data.table usage. See [#5604](https://github.com/Rdatatable/data.table/issues/5604) and [#5277](https://github.com/Rdatatable/data.table/issues/5277). Thanks to @tdhock for the suggestions and @Nj221102 for implementing this improvement. + +--- # data.table [v1.15.0](https://github.com/Rdatatable/data.table/milestone/29) (30 Jan 2024) From a97152965ebde9c6e1d1088fce006fac1595976d Mon Sep 17 00:00:00 2001 From: nitish jha Date: Fri, 7 Jun 2024 07:51:59 +0530 Subject: [PATCH 08/24] updating news item --- NEWS.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 24361691d..94c27529d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -96,9 +96,7 @@ 14. `setNumericRounding()` now invisibly returns the old rounding value instead of `NULL`, which is now consistent with similar behavior by `setwd()`, `options()`, etc. Thanks @MichaelChirico for the report and @joshhwuu for the fix. -15. `.`, `J`, `measure`, and `patterns` are now exported to support non-standard evaluation (NSE) constructs within `[` and `melt()` functions. Previously, only `.N`, `.I`, `.GRP`, `.GRPI`, `.SD`, and `:=` were exported. This update ensures that these constructs are consistently available, maintaining consistency and functionality across your data.table usage. See [#5604](https://github.com/Rdatatable/data.table/issues/5604) and [#5277](https://github.com/Rdatatable/data.table/issues/5277). Thanks to @tdhock for the suggestions and @Nj221102 for implementing this improvement. - ---- +15. `.`, `J`, `measure`, and `patterns` are now exported for use within `[` and `melt()` functions. Previously, only `.N`, `.I`, `.GRP`, `.GRPI`, `.SD`, and `:=` were exported. This change helps package developers avoid defining these constructs inside functions, thereby preventing CRAN NOTES and ensuring consistency in data.table usage. See [#5604](https://github.com/Rdatatable/data.table/issues/5604) and [#5277](https://github.com/Rdatatable/data.table/issues/5277). Thanks to @tdhock for the suggestions and @Nj221102 for implementing this improvement. # data.table [v1.15.0](https://github.com/Rdatatable/data.table/milestone/29) (30 Jan 2024) From fc2459d8e5c0dfa36b7ce620ec659f61f0fed8a2 Mon Sep 17 00:00:00 2001 From: nitish jha Date: Sat, 8 Jun 2024 11:52:39 +0530 Subject: [PATCH 09/24] updated news item --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 94c27529d..42aab80b0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -96,7 +96,7 @@ 14. `setNumericRounding()` now invisibly returns the old rounding value instead of `NULL`, which is now consistent with similar behavior by `setwd()`, `options()`, etc. Thanks @MichaelChirico for the report and @joshhwuu for the fix. -15. `.`, `J`, `measure`, and `patterns` are now exported for use within `[` and `melt()` functions. Previously, only `.N`, `.I`, `.GRP`, `.GRPI`, `.SD`, and `:=` were exported. This change helps package developers avoid defining these constructs inside functions, thereby preventing CRAN NOTES and ensuring consistency in data.table usage. See [#5604](https://github.com/Rdatatable/data.table/issues/5604) and [#5277](https://github.com/Rdatatable/data.table/issues/5277). Thanks to @tdhock for the suggestions and @Nj221102 for implementing this improvement. +15. `.`, `J`, `measure`, and `patterns` are now exported for use within `[` and `melt()` functions, for consistency with`.N`, `.I`, `.GRP`, `.GRPI`, `.SD`, and `:=` which were the only previous NSE exports. This change helps package developers avoid defining these constructs inside functions, thereby preventing CRAN NOTES and ensuring consistency in data.table usage. See [#5604](https://github.com/Rdatatable/data.table/issues/5604) and [#5277](https://github.com/Rdatatable/data.table/issues/5277). Thanks to @tdhock for the suggestions and @Nj221102 for implementing this improvement. # data.table [v1.15.0](https://github.com/Rdatatable/data.table/milestone/29) (30 Jan 2024) From 8dc023ace1707d867e41b3eb285b17981c012850 Mon Sep 17 00:00:00 2001 From: Nitish Jha <151559388+Nj221102@users.noreply.github.com> Date: Sat, 8 Jun 2024 12:25:20 +0530 Subject: [PATCH 10/24] Update NEWS.md --- NEWS.md | 1 - 1 file changed, 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 5b07e4eea..e9ad86684 100644 --- a/NEWS.md +++ b/NEWS.md @@ -96,7 +96,6 @@ 14. `setNumericRounding()` now invisibly returns the old rounding value instead of `NULL`, which is now consistent with similar behavior by `setwd()`, `options()`, etc. Thanks @MichaelChirico for the report and @joshhwuu for the fix. - 15. `.`, `J`, `measure`, and `patterns` are now exported for use within `[` and `melt()` functions, for consistency with`.N`, `.I`, `.GRP`, `.GRPI`, `.SD`, and `:=` which were the only previous NSE exports. This change helps package developers avoid defining these constructs inside functions, thereby preventing CRAN NOTES and ensuring consistency in data.table usage. See [#5604](https://github.com/Rdatatable/data.table/issues/5604) and [#5277](https://github.com/Rdatatable/data.table/issues/5277). Thanks to @tdhock for the suggestions and @Nj221102 for implementing this improvement. 16. `dcast()` now issues a warning when `fun.aggregate` is used but not provided by the user. `fun.aggregate` defaults to `length` in this case. Previously, only a message was issued. However, relying on this default often signals unexpected duplicates in the data. Therefore, a stricter class of signal was deemed more appropriate, [#5386](https://github.com/Rdatatable/data.table/issues/5386). The warning is classed as `dt_missing_fun_aggregate_warning`, allowing for more targeted handling in user code. Thanks @MichaelChirico for the suggestion and @Nj221102 for the fix. From adfac00a32eea88bedfd208e3b9f3685b7113f7d Mon Sep 17 00:00:00 2001 From: Nitish Jha <151559388+Nj221102@users.noreply.github.com> Date: Sat, 8 Jun 2024 12:27:07 +0530 Subject: [PATCH 11/24] Update NEWS.md --- NEWS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index e9ad86684..0baeb36e5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -96,9 +96,9 @@ 14. `setNumericRounding()` now invisibly returns the old rounding value instead of `NULL`, which is now consistent with similar behavior by `setwd()`, `options()`, etc. Thanks @MichaelChirico for the report and @joshhwuu for the fix. -15. `.`, `J`, `measure`, and `patterns` are now exported for use within `[` and `melt()` functions, for consistency with`.N`, `.I`, `.GRP`, `.GRPI`, `.SD`, and `:=` which were the only previous NSE exports. This change helps package developers avoid defining these constructs inside functions, thereby preventing CRAN NOTES and ensuring consistency in data.table usage. See [#5604](https://github.com/Rdatatable/data.table/issues/5604) and [#5277](https://github.com/Rdatatable/data.table/issues/5277). Thanks to @tdhock for the suggestions and @Nj221102 for implementing this improvement. +15. `dcast()` now issues a warning when `fun.aggregate` is used but not provided by the user. `fun.aggregate` defaults to `length` in this case. Previously, only a message was issued. However, relying on this default often signals unexpected duplicates in the data. Therefore, a stricter class of signal was deemed more appropriate, [#5386](https://github.com/Rdatatable/data.table/issues/5386). The warning is classed as `dt_missing_fun_aggregate_warning`, allowing for more targeted handling in user code. Thanks @MichaelChirico for the suggestion and @Nj221102 for the fix. -16. `dcast()` now issues a warning when `fun.aggregate` is used but not provided by the user. `fun.aggregate` defaults to `length` in this case. Previously, only a message was issued. However, relying on this default often signals unexpected duplicates in the data. Therefore, a stricter class of signal was deemed more appropriate, [#5386](https://github.com/Rdatatable/data.table/issues/5386). The warning is classed as `dt_missing_fun_aggregate_warning`, allowing for more targeted handling in user code. Thanks @MichaelChirico for the suggestion and @Nj221102 for the fix. +16. `.`, `J`, `measure`, and `patterns` are now exported for use within `[` and `melt()` functions, for consistency with`.N`, `.I`, `.GRP`, `.GRPI`, `.SD`, and `:=` which were the only previous NSE exports. This change helps package developers avoid defining these constructs inside functions, thereby preventing CRAN NOTES and ensuring consistency in data.table usage. See [#5604](https://github.com/Rdatatable/data.table/issues/5604) and [#5277](https://github.com/Rdatatable/data.table/issues/5277). Thanks to @tdhock for the suggestions and @Nj221102 for implementing this improvement. # data.table [v1.15.0](https://github.com/Rdatatable/data.table/milestone/29) (30 Jan 2024) From 5df74037f113ebe82a21c730abdb1cac4d94c5be Mon Sep 17 00:00:00 2001 From: nitish jha Date: Thu, 13 Jun 2024 20:57:15 +0530 Subject: [PATCH 12/24] updating news --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 09ca8790c..c7e7c015e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -98,7 +98,7 @@ 15. `dcast()` now issues a warning when `fun.aggregate` is used but not provided by the user. `fun.aggregate` defaults to `length` in this case. Previously, only a message was issued. However, relying on this default often signals unexpected duplicates in the data. Therefore, a stricter class of signal was deemed more appropriate, [#5386](https://github.com/Rdatatable/data.table/issues/5386). The warning is classed as `dt_missing_fun_aggregate_warning`, allowing for more targeted handling in user code. Thanks @MichaelChirico for the suggestion and @Nj221102 for the fix. -16. `.`, `J`, `measure`, and `patterns` are now exported for use within `[` and `melt()` functions, for consistency with`.N`, `.I`, `.GRP`, `.GRPI`, `.SD`, and `:=` which were the only previous NSE exports. This change helps package developers avoid defining these constructs inside functions, thereby preventing CRAN NOTES and ensuring consistency in data.table usage. See [#5604](https://github.com/Rdatatable/data.table/issues/5604) and [#5277](https://github.com/Rdatatable/data.table/issues/5277). Thanks to @tdhock for the suggestions and @Nj221102 for implementing this improvement. +16. `.`, `J`, `measure`, and `patterns` are now exported for use within `[` and `melt()` functions, for consistency with`.N`, `.I`, `.GRP`, `.GRPI`, `.SD`, and `:=` which were the only previous NSE exports. This change means that package developers will no longer see CRAN NOTEs about these being undefined variables, and no longer need to provide dummy/NULL definitions of these in order to avoid such NOTEs. See [#5604](https://github.com/Rdatatable/data.table/issues/5604) and [#5277](https://github.com/Rdatatable/data.table/issues/5277). Thanks to @tdhock for the suggestions and @Nj221102 for implementing this improvement. ## TRANSLATIONS From 6751a2bb689448034306005608cd118c8a32ef1c Mon Sep 17 00:00:00 2001 From: nitish jha Date: Thu, 13 Jun 2024 21:36:56 +0530 Subject: [PATCH 13/24] delete comment --- R/data.table.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/data.table.R b/R/data.table.R index 131ed2613..3abfbb9a4 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -16,7 +16,6 @@ methods::setPackageName("data.table",.global) J = function(...) NULL # These are exported to prevent NOTEs from R CMD check, and checkUsage via compiler. # But also exporting them makes it clear (to users and other packages) that data.table uses these as symbols. -# The use of NULL during loading signals to R's mask check that these entities aren't defined with specific behaviors. # utils::globalVariables(c(".SD",".N")) was tried as well, but exporting seems better. # So even though .BY doesn't appear in this file, it should still be NULL here and exported because it's # defined in SDenv and can be used by users. From 4058118ed51a7e9b3e84202e2eeb3be2a034b893 Mon Sep 17 00:00:00 2001 From: nitish jha Date: Wed, 19 Jun 2024 12:54:46 +0530 Subject: [PATCH 14/24] updated test and mask for J --- R/data.table.R | 4 +++- inst/tests/tests.Rraw | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/R/data.table.R b/R/data.table.R index 3abfbb9a4..0d72a01e8 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -13,7 +13,9 @@ methods::setPackageName("data.table",.global) # (3) add to vignettes/datatable-importing.Rmd#globals section .SD = .N = .I = .GRP = .NGRP = .BY = .EACHI = NULL . = function(...) NULL -J = function(...) NULL +J = function(...) { + stopf("Hey you shouldn't call that here/there's probably a mistake") +} # These are exported to prevent NOTEs from R CMD check, and checkUsage via compiler. # But also exporting them makes it clear (to users and other packages) that data.table uses these as symbols. # utils::globalVariables(c(".SD",".N")) was tried as well, but exporting seems better. diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index a8eba2e9b..0f30aafa8 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -2186,7 +2186,7 @@ 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), NULL) +test(715, J(a=1:3,b=4), error="Hey you shouldn't call that here/there's probably a mistake") # Test get in j DT = data.table(a=1:3,b=4:6) From 22f97064493f2080ffb4ef5ce187677993cc4a06 Mon Sep 17 00:00:00 2001 From: nitish jha Date: Wed, 19 Jun 2024 20:08:29 +0530 Subject: [PATCH 15/24] improved the error message --- R/data.table.R | 8 ++++++-- inst/tests/tests.Rraw | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/R/data.table.R b/R/data.table.R index 0d72a01e8..9e7476bd9 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -12,10 +12,14 @@ methods::setPackageName("data.table",.global) # (2) export() in NAMESPACE # (3) add to vignettes/datatable-importing.Rmd#globals section .SD = .N = .I = .GRP = .NGRP = .BY = .EACHI = NULL -. = function(...) NULL J = function(...) { - stopf("Hey you shouldn't call that here/there's probably a mistake") + stopf("The function 'J' should not be called here. 'J' is intended for use within the 'j' expression of data.table operations") } + +. = function(...) { + stopf("The symbol '.' should not be used here. '.' is intended for use within data.table operations.") +} + # These are exported to prevent NOTEs from R CMD check, and checkUsage via compiler. # But also exporting them makes it clear (to users and other packages) that data.table uses these as symbols. # utils::globalVariables(c(".SD",".N")) was tried as well, but exporting seems better. diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 0f30aafa8..6ef29216a 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -2186,7 +2186,7 @@ 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="Hey you shouldn't call that here/there's probably a mistake") +test(715, J(a=1:3,b=4), error="The function 'J' should not be called here.") # Test get in j DT = data.table(a=1:3,b=4:6) From 40101d48b8fe3f6551ac56617887806849ccc534 Mon Sep 17 00:00:00 2001 From: nitish jha Date: Wed, 19 Jun 2024 21:19:41 +0530 Subject: [PATCH 16/24] updated error messages --- R/data.table.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/data.table.R b/R/data.table.R index 9e7476bd9..e0609d705 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -13,11 +13,11 @@ methods::setPackageName("data.table",.global) # (3) add to vignettes/datatable-importing.Rmd#globals section .SD = .N = .I = .GRP = .NGRP = .BY = .EACHI = NULL J = function(...) { - stopf("The function 'J' should not be called here. 'J' is intended for use within the 'j' expression of data.table operations") + stopf("The function 'J' should not be called here. 'J' is intended for use within the 'i' arguement of data.table operations") } . = function(...) { - stopf("The symbol '.' should not be used here. '.' is intended for use within data.table operations.") + stopf("The symbol '.' should not be used here. '.' can be used as an alias for 'list' within the square brackets of a data.table, DT[.]") } # These are exported to prevent NOTEs from R CMD check, and checkUsage via compiler. From 1dc2c2cfd53b6a6c85de20879fda5992beab00ee Mon Sep 17 00:00:00 2001 From: nitish jha Date: Thu, 20 Jun 2024 03:31:53 +0530 Subject: [PATCH 17/24] improving error message --- R/data.table.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/data.table.R b/R/data.table.R index e0609d705..3af655a83 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -13,11 +13,11 @@ methods::setPackageName("data.table",.global) # (3) add to vignettes/datatable-importing.Rmd#globals section .SD = .N = .I = .GRP = .NGRP = .BY = .EACHI = NULL J = function(...) { - stopf("The function 'J' should not be called here. 'J' is intended for use within the 'i' arguement of data.table operations") + stopf("The function 'J' should not be called here. 'J' is intended for use within the 'i' argument of data.table operations") } . = function(...) { - stopf("The symbol '.' should not be used here. '.' can be used as an alias for 'list' within the square brackets of a data.table, DT[.]") + stopf("The function '.' should not be called here. '.' can be used as an alias for 'list' within the square brackets of a data.table, DT[.]") } # These are exported to prevent NOTEs from R CMD check, and checkUsage via compiler. From 5ebd8b6637e364ac71ea25850a17cc42e804de90 Mon Sep 17 00:00:00 2001 From: Nitish Jha <151559388+Nj221102@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:23:35 +0530 Subject: [PATCH 18/24] Update NEWS.md Co-authored-by: Michael Chirico --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index d84b295fc..a4dd5f92a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -100,7 +100,7 @@ 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()` functions, for consistency with`.N`, `.I`, `.GRP`, `.GRPI`, `.SD`, and `:=` which were the only previous NSE exports. This change means that package developers will no longer see CRAN NOTEs about these being undefined variables, and no longer need to provide dummy/NULL definitions of these in order to avoid such NOTEs. See [#5604](https://github.com/Rdatatable/data.table/issues/5604) and [#5277](https://github.com/Rdatatable/data.table/issues/5277). Thanks to @tdhock for the suggestions and @Nj221102 for implementing this improvement. +17. `.`, `J`, `measure`, and `patterns` are now exported for use within `[` and `melt()` functions, for consistency with`.N`, `.I`, `.GRP`, `.GRPI`, `.SD`, and `:=` which were the only previous NSE exports. This change means that package developers can simply import these names to avoid `R CMD check` `NOTE`s about these being undefined variables. See [#5604](https://github.com/Rdatatable/data.table/issues/5604) and [#5277](https://github.com/Rdatatable/data.table/issues/5277). Thanks to @tdhock for the suggestions and @Nj221102 for implementing. ## TRANSLATIONS From 1d61cce9eecbbfc49d8042367c95606aa3ca3b25 Mon Sep 17 00:00:00 2001 From: nitish jha Date: Thu, 20 Jun 2024 11:30:30 +0530 Subject: [PATCH 19/24] small changes --- R/data.table.R | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/R/data.table.R b/R/data.table.R index 3af655a83..f4d1f0268 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -12,16 +12,9 @@ methods::setPackageName("data.table",.global) # (2) export() in NAMESPACE # (3) add to vignettes/datatable-importing.Rmd#globals section .SD = .N = .I = .GRP = .NGRP = .BY = .EACHI = NULL -J = function(...) { - stopf("The function 'J' should not be called here. 'J' is intended for use within the 'i' argument of data.table operations") -} - -. = function(...) { - stopf("The function '.' should not be called here. '.' can be used as an alias for 'list' within the square brackets of a data.table, DT[.]") -} - # These are exported to prevent NOTEs from R CMD check, and checkUsage via compiler. # But also exporting them makes it clear (to users and other packages) that data.table uses these as symbols. +# And NULL makes it clear (to the R's mask check on loading) that they're variables not functions. # utils::globalVariables(c(".SD",".N")) was tried as well, but exporting seems better. # So even though .BY doesn't appear in this file, it should still be NULL here and exported because it's # defined in SDenv and can be used by users. @@ -2777,6 +2770,14 @@ 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(":=").') } +J = function(...) { + stopf("The function 'J' should not be called here. 'J' is intended for use within the 'i' argument of data.table operations") +} + +. = function(...) { + stopf("The function '.' should not be called here. '.' can be used as an alias for 'list' within the square brackets of a data.table, DT[.]") +} + let = function(...) `:=`(...) setDF = function(x, rownames=NULL) { From 127b45e7867610e3e87254f4631f3a3df7474e3b Mon Sep 17 00:00:00 2001 From: Nitish Jha <151559388+Nj221102@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:37:43 +0530 Subject: [PATCH 20/24] Update vignettes/datatable-importing.Rmd Co-authored-by: Michael Chirico --- vignettes/datatable-importing.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/datatable-importing.Rmd b/vignettes/datatable-importing.Rmd index 6bbb74b6e..9f5d089b9 100644 --- a/vignettes/datatable-importing.Rmd +++ b/vignettes/datatable-importing.Rmd @@ -118,7 +118,7 @@ aggr = function (x) { } ``` -The case for `data.table`'s special symbols (`.SD`, `.BY`, `.N`, `.I`, `.GRP`, `.NGRP`, `.`, `J`, `patterns`, `measure` and `.EACHI`; see `?.N`) and assignment operator (`:=`) is slightly different. You should import whichever of these values you use from `data.table`'s namespace to protect against any issues arising from the unlikely scenario that we change the exported value of these in the future, e.g. if you want to use `.N`, `.I`, and `:=`, a minimal `NAMESPACE` would have: +The case for `data.table`'s special symbols (e.g. `.SD` and `.N`) and assignment operator (`:=`) is slightly different (see `?.N` for more, including a complete listing of such symbols). You should import whichever of these values you use from `data.table`'s namespace to protect against any issues arising from the unlikely scenario that we change the exported value of these in the future, e.g. if you want to use `.N`, `.I`, and `:=`, a minimal `NAMESPACE` would have: ```r importFrom(data.table, .N, .I, ':=') From 90cd87381e4eabdb311f355dca04c9fcd99d8b80 Mon Sep 17 00:00:00 2001 From: Nitish Jha <151559388+Nj221102@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:37:55 +0530 Subject: [PATCH 21/24] Update NEWS.md Co-authored-by: Michael Chirico --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index a4dd5f92a..901b922fb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -100,7 +100,7 @@ 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()` functions, for consistency with`.N`, `.I`, `.GRP`, `.GRPI`, `.SD`, and `:=` which were the only previous NSE exports. This change means that package developers can simply import these names to avoid `R CMD check` `NOTE`s about these being undefined variables. See [#5604](https://github.com/Rdatatable/data.table/issues/5604) and [#5277](https://github.com/Rdatatable/data.table/issues/5277). Thanks to @tdhock for the suggestions and @Nj221102 for implementing. +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 these being undefined variables. Thanks to @MichaelChirico and @ylelkes for the suggestions and @Nj221102 for implementing. ## TRANSLATIONS From 87e50e1c180202684f40b659f2a435bca0c6f2e9 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Wed, 19 Jun 2024 23:09:15 -0700 Subject: [PATCH 22/24] grammar --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 901b922fb..af87e3eeb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -100,7 +100,7 @@ 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 these being undefined variables. Thanks to @MichaelChirico and @ylelkes for the suggestions and @Nj221102 for implementing. +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. ## TRANSLATIONS From 80c56eb1d4fd7a5e8752eac387a12c8b691ba83b Mon Sep 17 00:00:00 2001 From: nitish jha Date: Thu, 20 Jun 2024 11:40:46 +0530 Subject: [PATCH 23/24] updating error message --- R/data.table.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/data.table.R b/R/data.table.R index f4d1f0268..fcca49560 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -2771,11 +2771,11 @@ address = function(x) .Call(Caddress, eval(substitute(x), parent.frame())) } J = function(...) { - stopf("The function 'J' should not be called here. 'J' is intended for use within the 'i' argument of data.table operations") + stopf("J() called outside of [.data.table. J() is only intended for use in i.") } . = function(...) { - stopf("The function '.' should not be called here. '.' can be used as an alias for 'list' within the square brackets of a data.table, DT[.]") + stopf(".() called outside of [.data.table. .() is only intended as an alias for list() inside DT[...].") } let = function(...) `:=`(...) From ea846078aebfc35e0d74df88aba0e098f1d37e36 Mon Sep 17 00:00:00 2001 From: nitish jha Date: Thu, 20 Jun 2024 11:45:20 +0530 Subject: [PATCH 24/24] updating example --- inst/tests/tests.Rraw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index d5fb27d0d..b0b37ec8a 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -2186,7 +2186,7 @@ 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="The function 'J' should not be called here.") +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)