Description Usage Arguments Details Examples
Patch purrr to allow an extended anonymous function syntax.
1 | patch_purrr_mapper(envir = parent.frame())
|
envir |
default: parent.frame() |
Purrr uses the generic as_mapper()
to determine how to convert the function in a
map()
call into an actual function. There are methods which deal with
character values, lists and numerics. There is no method which deals explicitly with
forumulas - instead a formula will just fall through to as_mapper.default()
.
So by creating as_mapper.formula()
we can catch any formulas before
purrr::as_mapper.default()
and convert them into a function using
anon::as_function_formula()
Note: This doesn't really patch purrr, it just adds another function to your environment. It certainly feels like patching/monkey-patching the package though, so that's why it's named as such.
1 2 3 4 5 6 | ## Not run:
library(anon)
patch_purrr_mapper()
map(1:3, ~value + 1)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.