as_function: Convert an object into a function.

Description Usage Arguments

View source: R/utils.R

Description

as_function is the powerhouse behind the varied function specifications that purrr functions allow. This is a a non-exported, modified version that does not turn character vectors into functions, instead it simply returns objects that are not functions or formulas as-is.

Usage

1

Arguments

.f

A function, formula, or atomic vector.

If a function, it is used as is.

If a formula, e.g. ~ .x + 2, it is converted to a function with two arguments, .x or . and .y. This allows you to create very compact anonymous functions with up to two inputs.

If anything else, return it as-is.


jakesherman/missr documentation built on May 18, 2019, 9:08 a.m.