x.names.from.formula: (Internal) Get names of explanatory variables (excluding...

View source: R/utils.r

x.names.from.formulaR Documentation

(Internal) Get names of explanatory variables (excluding random factor) from formula.

Description

(Internal) Get names of explanatory variables (excluding random factor) from formula.

Usage

x.names.from.formula(
  formula,
  data = NULL,
  specials = NULL,
  type = c("all", "base")
)

Arguments

formula

a formula object from which variable names are obtained.

data

a data.frame used to expand . in the formula.

specials

special characterss passed to terms.formula.

type

a character literal specifying type of explanatory variables to get.

Value

a character vector of names of explanatory variables. If type is "all", returns all explanatory variables in the formula as is. If type is "base", this function returns all explanatory variables in their basic form.

Examples


# Getting explanatory variables from formula.
# . in formula is expanded to full form.
data(iris)
f <- Sepal.Length ~ .
model.adapter:::x.names.from.formula(f, data = iris)

# Getting explanatory variables in their basic form.
f <- Sepal.Length ~ Petal.Length + Petal.Length:Species + I(Sepal.Width ^ 2)
model.adapter:::x.names.from.formula(f, data = iris, type = "base")

Marchen/model.adapter documentation built on July 3, 2023, 11:07 a.m.