Learn R Programming

workflowsets (version 1.1.0)

leave_var_out_formulas: 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, ...)

Value

A named list of formulas

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).

See Also

workflow_set()

Examples

Run this code
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
)

Run the code above in your browser using DataLab