Learn R Programming

SSBtools (version 1.7.0)

combine_formulas: Combine formulas

Description

Combining formulas by + or another operator. This is particularly useful for linking tables in the case of table building with formulas.

Usage

combine_formulas(lof, operator = "+", simplify = FALSE, env = parent.frame())

Value

model formula

Arguments

lof

list or vector of formulas to be linked

operator

"+" (default), "*", ":" or another operator

simplify

logical value, default 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
lof1 <- c(~a+b, ~a:c, ~c*d)
combine_formulas(lof1)
combine_formulas(lof1, operator = "*")
combine_formulas(lof1, simplify = TRUE)

# Intercept is included when needed
lof2 <- c(~a+b -1, ~a:c -1, ~c*d)
combine_formulas(lof2)
combine_formulas(lof2, simplify = TRUE)
combine_formulas(lof2[1:2])
combine_formulas(lof2[1:2], simplify = TRUE)

Run the code above in your browser using DataLab