Learn R Programming

bazar (version 1.0.11)

get_vars: Get formula variables

Description

The function get_vars extracts variable names from a formula.

Usage

get_vars(formula, data = NULL, intersection = TRUE)

Arguments

formula

a formula.

data

data.frame or matrix. If not NULL, formulas with a dot . are permitted.

intersection

logical. If TRUE and data is not NULL, the intersection between variables found in the formula and data column names is returned.

Value

a character vector, the variables found.

See Also

all.vars, get.vars

Examples

Run this code
# NOT RUN {
get_vars(y ~ x1 + x2 - x1)
get_vars(y ~ . - x1, data = data.frame(y = 1, x1 = 2, x2 = 3))
get_vars(y + z ~ x1 + x2 - x1 | x3)
get_vars(y ~ x1 + I(log(x2)))
get_vars(y ~ x1*x2)
get_vars(y ~ x1:x2)
get_vars(~ x1 + x2)

# }

Run the code above in your browser using DataLab