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.
# Fit a linear modelmodel <- lm(mpg ~ wt + hp, data = mtcars)
# Print a plain-text version to the consolemodel.summary.table(model, caption = "Linear Model Summary", latex = FALSE)