Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export masks for NSE-only constructs ., J, patterns and measure #6125

Merged
merged 34 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
16683b2
masking function
May 6, 2024
06841af
Merge branch 'master' into Masking-functions
Nj221102 May 6, 2024
0003f9a
Update data.table.R
Nj221102 May 9, 2024
f63ae30
Merge branch 'master' into Masking-functions
Nj221102 May 27, 2024
070978c
Merge branch 'master' into Masking-functions
Nj221102 Jun 1, 2024
86ea33c
Removed mask for pattern and measure
Jun 1, 2024
6700f0e
Merge branch 'master' into Masking-functions
Nj221102 Jun 2, 2024
e1772e6
exporting pattern and measure
Jun 3, 2024
3095edd
Merge branch 'master' into Masking-functions
Nj221102 Jun 3, 2024
a1fdd4e
added news entry
Jun 3, 2024
bda02d8
editing news item
Jun 3, 2024
82ca538
updating news
Jun 4, 2024
a971529
updating news item
Jun 7, 2024
fc2459d
updated news item
Jun 8, 2024
4715f4e
Merge branch 'master' into Masking-functions
Nj221102 Jun 8, 2024
8dc023a
Update NEWS.md
Nj221102 Jun 8, 2024
adfac00
Update NEWS.md
Nj221102 Jun 8, 2024
628f4df
Merge branch 'master' into Masking-functions
Nj221102 Jun 13, 2024
5df7403
updating news
Jun 13, 2024
6751a2b
delete comment
Jun 13, 2024
7f1cfed
Merge branch 'master' into Masking-functions
Nj221102 Jun 19, 2024
4058118
updated test and mask for J
Jun 19, 2024
22f9706
improved the error message
Jun 19, 2024
40101d4
updated error messages
Jun 19, 2024
1dc2c2c
improving error message
Jun 19, 2024
3510565
Merge branch 'master' into Masking-functions
Nj221102 Jun 20, 2024
5ebd8b6
Update NEWS.md
Nj221102 Jun 20, 2024
82ca346
Merge branch 'master' into Masking-functions
Nj221102 Jun 20, 2024
1d61cce
small changes
Jun 20, 2024
127b45e
Update vignettes/datatable-importing.Rmd
Nj221102 Jun 20, 2024
90cd873
Update NEWS.md
Nj221102 Jun 20, 2024
87e50e1
grammar
MichaelChirico Jun 20, 2024
80c56eb
updating error message
Jun 20, 2024
ea84607
updating example
Jun 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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, measure, patterns)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: I imagine this (.) will break some revdeps. Let's see.

export(rleid)
export(rleidv)
export(rowid)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@

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.

## TRANSLATIONS

1. Fix a typo in a Mandarin translation of an error message that was hiding the actual error message, [#6172](https://github.com/Rdatatable/data.table/issues/6172). Thanks @trafficfan for the report and @MichaelChirico for the fix.
Expand Down
8 changes: 8 additions & 0 deletions R/data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -2770,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("J() called outside of [.data.table. J() is only intended for use in i.")
}

. = function(...) {
stopf(".() called outside of [.data.table. .() is only intended as an alias for list() inside DT[...].")
}

let = function(...) `:=`(...)

setDF = function(x, rownames=NULL) {
Expand Down
2 changes: 1 addition & 1 deletion inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -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=base_messages$missing_function("J"))
test(715, J(a=1:3,b=4), error="J() called outside of [.data.table. J() is only intended for use in i.")
MichaelChirico marked this conversation as resolved.
Show resolved Hide resolved

# Test get in j
DT = data.table(a=1:3,b=4:6)
Expand Down
2 changes: 1 addition & 1 deletion vignettes/datatable-importing.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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 (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, ':=')
Expand Down
Loading