model.equation: Generate a Model Equation from a Linear Model

View source: R/model.equation.R

model.equationR Documentation

Generate a Model Equation from a Linear Model

Description

This function extracts and formats the equation from a linear model object. It includes an option to return the equation as a LaTeX-formatted string or print it to the console.

Usage

model.equation(model, latex = TRUE)

Arguments

model

A linear model object (e.g., output from 'lm()').

latex

A logical value indicating whether to return a LaTeX-formatted equation (default: TRUE). If FALSE, the equation is printed to the console.

Value

If 'latex' is TRUE, the equation is returned as LaTeX code using 'knitr::asis_output()'. If FALSE, the equation is printed to the console.

Examples

# Fit a linear model
model <- lm(mpg ~ wt + hp, data = mtcars)

# Get LaTeX equation
model.equation(model)

# Print equation to console
print(model.equation(model, latex = FALSE))


snazzieR documentation built on April 3, 2025, 5:58 p.m.