Learn R Programming

SSBtools (version 1.7.0)

substitute_formula_vars: Replace variables in formula with sum of other variables

Description

Replace variables in formula with sum of other variables

Usage

substitute_formula_vars(
  f,
  replacements,
  simplify = FALSE,
  env = parent.frame()
)

Value

model formula

Arguments

f

A model formula.

replacements

A named list. The names of replacements must correspond to variables in f. Each element in replacements must be a character vector consisting of the variables you wish to replace.

simplify

Logical, default is FALSE. Determines whether the formula should be expanded and simplified before output or not.

env

The environment for the output formula.

Author

Daniel Lupp and Øyvind Langsrud

Examples

Run this code
f <- ~b + a*c  + b:d
substitute_formula_vars(f, list(a = c("hello", "world", "b"), 
                                b = c("Q1", "Q2")))

Run the code above in your browser using DataLab