Learn R Programming

snazzieR (version 0.1.2)

model.summary.table: Generate a Summary Table for a Linear Model

Description

This function creates a summary table for a linear model, including estimated coefficients, standard errors, p-values with significance codes, and model statistics such as MSE and R-squared. The table can be output as either LaTeX (for PDF reports) or plain text (for console viewing).

Usage

model.summary.table(model, caption, latex = TRUE)

Value

If `latex = TRUE`, returns a LaTeX-formatted `kableExtra` table object. If `latex = FALSE`, prints formatted summary tables to the console and returns the underlying data frame.

Arguments

model

A linear model object (typically the result of `lm()`).

caption

A character string to be used as the caption for the table.

latex

Logical; if `TRUE` (default), returns a LaTeX-formatted table using `kableExtra`. If `FALSE`, prints plain-text summary tables to the console.

Examples

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

# Print a plain-text version to the console
model.summary.table(model, caption = "Linear Model Summary", latex = FALSE)

Run the code above in your browser using DataLab