patch_purrr_mapper: use 'anon::as_function_formula()' in 'purrr' to extend the...

Description Usage Arguments Details Examples

Description

Patch purrr to allow an extended anonymous function syntax.

Usage

1

Arguments

envir

default: parent.frame()

Details

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.

Examples

1
2
3
4
5
6
## Not run: 
library(anon)
patch_purrr_mapper()
map(1:3, ~value + 1)

## End(Not run)

coolbutuseless/anon documentation built on Jan. 13, 2020, 4:38 a.m.