View source: R/simplify_formula.R
simplify_formula | R Documentation |
Extracts all variables from a formula object and creates a new formula with all predictor variables added together without the inline functions.
E.g.:
y ~ x*z + log(a) + (1|b)
becomes
y ~ x + z + a + b
.
This is useful when passing a formula to recipes::recipe()
for preprocessing a dataset, as used in the
preprocess_functions()
.
simplify_formula(formula, data = NULL, string_out = FALSE)
formula |
Formula object. If a string is passed, it will be converted with When a side only contains a An intercept ( |
data |
|
string_out |
Whether to return as a string. (Logical) |
Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk
# Attach cvms
library(cvms)
# Create formula
f1 <- "y ~ x*z + log(a) + (1|b)"
# Simplify formula (as string)
simplify_formula(f1)
# Simplify formula (as formula)
simplify_formula(as.formula(f1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.