leave_var_out_formulas: Create formulas without each predictor

View source: R/leave_var_out_formulas.R

leave_var_out_formulasR Documentation

Create formulas without each predictor

Description

From an initial model formula, create a list of formulas that exclude each predictor.

Usage

leave_var_out_formulas(formula, data, full_model = TRUE, ...)

Arguments

formula

A model formula that contains at least two predictors.

data

A data frame.

full_model

A logical; should the list include the original formula?

...

Options to pass to stats::model.frame()

Details

The new formulas obey the hierarchy rule so that interactions without main effects are not included (unless the original formula contains such terms).

Factor predictors are left as-is (i.e., no indicator variables are created).

Value

A named list of formulas

See Also

workflow_set()

Examples

data(penguins, package = "modeldata")

leave_var_out_formulas(
  bill_length_mm ~ .,
  data = penguins
)

leave_var_out_formulas(
  bill_length_mm ~ (island + sex)^2 + flipper_length_mm,
  data = penguins
)

leave_var_out_formulas(
  bill_length_mm ~ (island + sex)^2 + flipper_length_mm +
    I(flipper_length_mm^2),
  data = penguins
)

workflowsets documentation built on April 7, 2023, 1:05 a.m.