form_pred: Extract Predictor Names from Formula or Terms

Description Usage Arguments Value Examples

Description

'all.vars' returns all variables used in a formula. This function only returns the variables explicitly used on the right-hand side (i.e., it will not resolve dots unless the object is terms with a data set specified).

Usage

1
form_pred(object, ...)

Arguments

object

A model formula or [stats::terms()] object.

...

Arguments to pass to [all.vars()]

Value

A character vector of names

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
form_pred(y ~ x + z)
form_pred(terms(y ~ x + z))

form_pred(y ~ x + log(z))
form_pred(log(y) ~ x + z)

form_pred(y1 + y2 ~ x + z)
form_pred(log(y1) + y2 ~ x + z)

# will fail:
# form_pred(y ~ .)

form_pred(terms(Species ~ (.)^2, data = iris))
form_pred(terms( ~ (.)^2, data = iris))

topepo/rsample documentation built on May 4, 2019, 4:25 p.m.