We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Consider:
> f <- function(...) { ..2 } > f(a = 1, b = 2) [1] 2
If we attempt to get ..2 using globalsByName(), it does not find that argument;
..2
globalsByName()
> f <- function(...) { globals::globalsByName("..2") } > f(a = 1, b = 2) $..2 [1] NA attr(,"class") [1] "DotDotDotList" "logical" attr(,"where") attr(,"where")$..2 NULL attr(,"class") [1] "Globals" "list"
The reason is that the code assumes exists("..2") is TRUE, but that's not the case, e.g.
exists("..2")
> f <- function(...) { exists("..2") } > f(a = 1, b = 2) [1] FALSE
The solution is to work with .... Gist:
...
> f <- function(...) { globals <- globals::globalsByName("...") if (is.list(globals[["..."]])) { if (length(globals[["..."]]) < 2) stop("the ... list contains fewer than 2 elements") args<- globals[["..."]] args <- args[2L] class(args) <- class(globals[["..."]]) globals[["..."]] <- args globals } } > f(a = 1, b = 2) $... $b [1] 2 attr(,"class") [1] "DotDotDotList" "list" attr(,"where") attr(,"where")$... <environment: R_EmptyEnv> attr(,"class") [1] "Globals" "list"
The text was updated successfully, but these errors were encountered:
BUG FIX: globalsByName(), and therefore also globalsOf(), did not sup…
b70df15
…port special arguments '..1', ..2', etc. [#88]
Implemented;
> f <- function(...) { globals::globalsByName("..2") } g <- f(a = 1, b = 2, c = 3) str(g) List of 1 $ ..2:List of 1 ..$ : num 2 ..- attr(*, "class")= chr [1:2] "DotDotDotList" "list" - attr(*, "where")=List of 1 ..$ ..2:<environment: 0x557dae0e3d50> - attr(*, "class")= chr [1:2] "Globals" "list"
Sorry, something went wrong.
No branches or pull requests
Issue
Consider:
If we attempt to get
..2
usingglobalsByName()
, it does not find that argument;Troubleshooting
The reason is that the code assumes
exists("..2")
is TRUE, but that's not the case, e.g.Solution
The solution is to work with
...
. Gist:The text was updated successfully, but these errors were encountered: