as.function.formula: Coerce a formula into a function

Description Usage Arguments Value Examples

View source: R/as.function.R

Description

Convert a formula into a function. See map and extract for examples.

Usage

1
2
## S3 method for class 'formula'
as.function(x, ...)

Arguments

x

(formula) see examples

...

not used

Value

An object inheriting from class function.

Examples

1
2
3
4
5
as.function(~ .)(1)
as.function(x ~ x)(1)
as.function(f(x, y) ~ c(x, y))(1, 2)
as.function(numeric : x ~ x)(1) # check for class
as.function(numeric(1) : x ~ x)(1) # check for class + length

Example output

To use dplyr as backend set 'options(dat.use.dplyr = TRUE)'.

Attaching package:datThe following object is masked frompackage:base:

    replace

[1] 1
[1] 1
[1] 1 2
[1] 1
[1] 1

dat documentation built on July 1, 2020, 7:11 p.m.