-
Notifications
You must be signed in to change notification settings - Fork 255
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
Ellipsis in as_mapper #710
Comments
I think I found the (more general) answer to my question. Rewriting the map_paster <- function(z, ...) {
dots <- match.call(expand.dots = FALSE)$...
map(z, ~ paste0(.x, dots))
} ... suggests that we are supposed to use ellipsis in mapper functions (and all other nested functions in general) differently then in non-nested functions. However, it would still be interesting to know why the argument mapping goes wrong, when the ellipsis is passed as is into the nested-function/mapper function. |
Look at the definition : paster <- purrr::as_mapper(~ paste0(.x, ...))
paster
#> <lambda>
#> function (..., .x = ..1, .y = ..2, . = ..1)
#> paste0(.x, ...)
#> attr(,"class")
#> [1] "rlang_lambda_function" "function"
I'm not sure if We could reproduce the functionality though :
But it's probably not worth the trouble when you could use a regular |
Thanks for digging into this. I stumbled upon the issue on SO (see link in original post above) where When the function inside
I think this issue is not really an 'issue' and can be closed. |
We encountered an issue when using the ellipsis argument in
as_mapper
.It seems that when the ellipsis is included in the mapper function,
as_mapper
matches the first argument not only to.x
but also automatically to the ellipsis...
.Below is a short example of what is happening when using the ellipsis inside a mapper function.
The question now is:
Update
The above behavior does not appear, when specifying the
.x
argument explicitly in thepaster
function. It seems like...
is already used withinas_mapper
which leads to conflicts. I then wonder why not specifying the argument inpaster
will map the value to both.x
and...
.And while in the above example the specification of
.x
as argument is still possible, the argument matching insideas_mapper
becomes an actual issue when used inside a function (which is generally the case when using one of themap
-functions together with the lambda notion for .f~
).The text was updated successfully, but these errors were encountered: