make_fn_aware {nofrills} | R Documentation |
Make a function aware of abbreviated functional arguments
Description
make_fn_aware()
is a functional operator that enhances a function by
enabling it to interpret abbreviated functional arguments.
Usage
make_fn_aware(f, ...)
Arguments
f |
Function, or symbol or name of a function. |
... |
Name(s) of functional argument(s) of |
Value
A function with the same call signature as f
, but whose function
arguments, as designated by ...
, may be specified using an abbreviated
function expression of the form .(...)
, cf. as_fn()
. If ...
is empty
or NULL
, then f
is simply returned.
See Also
Examples
reduce <- make_fn_aware(Reduce, "f")
## reduce() behaves just like Reduce()
Reduce(function(u, v) u + 1 / v, c(3, 7, 15, 1, 292), right = TRUE)
reduce(function(u, v) u + 1 / v, c(3, 7, 15, 1, 292), right = TRUE)
## reduce() can also interpret abbreviated function expressions
reduce(.(u, v ~ u + 1 / v), c(3, 7, 15, 1, 292), right = TRUE)
[Package nofrills version 0.3.2 Index]