| Title: | Create Multi-Format Regression Tables |
|---|---|
| Description: | Create publication-ready regression tables in multiple formats, including 'Word', 'HTML', 'LaTeX', and 'PDF', from statistical models. Supports lm() and glm() models. Includes options for marginal effects, control variable grouping, and robust standard errors using methods described in Zeileis (2004) <doi:10.18637/jss.v011.i10>. Tables can be exported to 'Word' via 'flextable' or to 'LaTeX' for 'PDF' output. |
| Authors: | Alfredo Hernandez Sanchez [aut, cre] |
| Maintainer: | Alfredo Hernandez Sanchez <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 2.1.1 |
| Built: | 2026-05-12 21:26:30 UTC |
| Source: | https://github.com/cran/easytable |
Takes model objects as arguments and creates formatted tables for Word or LaTeX/PDF output. Supports robust standard errors, marginal effects, and control variable grouping.
easytable( ..., model.names = NULL, output = "word", export.word = NULL, export.csv = NULL, robust.se = FALSE, control.var = NULL, margins = FALSE, highlight = FALSE, abbreviate = FALSE, table_size = "normalsize", digits = 2, custom.row = NULL )easytable( ..., model.names = NULL, output = "word", export.word = NULL, export.csv = NULL, robust.se = FALSE, control.var = NULL, margins = FALSE, highlight = FALSE, abbreviate = FALSE, table_size = "normalsize", digits = 2, custom.row = NULL )
... |
Statistical model objects (lm or glm). Pass models directly
like |
model.names |
Character vector of custom names for model columns. If NULL (default), columns are named "Model 1", "Model 2", etc. Length must match number of models. |
output |
Character string specifying output format. One of:
|
export.word |
Character string ending in |
export.csv |
Character string ending in |
robust.se |
Logical. Use robust standard errors (HC type)? Default FALSE. Requires packages: lmtest, sandwich |
control.var |
Character vector of variable names to group as "control variables". These will be collapsed into single rows showing "Y" for presence instead of individual coefficients. Default NULL. |
margins |
Logical. Compute average marginal effects (AME)? Default FALSE. Requires package: margins |
highlight |
Logical. Highlight significant coefficients (positive in green, negative in red)? Default FALSE. Works best with Word output. |
abbreviate |
Logical. Abbreviate variable names for readability? Default FALSE. When TRUE, long variable names are shortened using deterministic rules. |
table_size |
Character string specifying LaTeX table size. Only works with
|
digits |
Number of digits after the decimal point for coefficients and standard errors, including the mantissa in scientific notation. Allowed values are 0 to 4. Default 2. |
custom.row |
Optional character vector for an additional row placed at the bottom of the statistics block. The first element is the row label and each subsequent element is the value for the corresponding model column. The vector must have exactly one more element than the number of models. Default NULL (no extra row). |
The function extracts coefficients, standard errors, and p-values from each
model, adds significance stars (*** p<.01, ** p<.05, * p<.1), and includes
model fit statistics such as N, R-squared, Adjusted R-squared, and
AIC (for glm models).
Control variables can be grouped to show presence/absence rather than individual coefficients for each factor level or transformation.
Term labels are automatically formatted for readability:
Factor levels separated with colon (e.g., advisor_confidence:low)
Interactions shown with a multiplication sign (e.g., var1 × var2)
Polynomial contrasts as L indices (e.g., var:L1, var:L2)
Long variable names abbreviated for clarity
Depends on output:
"word" - A flextable object
"latex" - Character string with LaTeX table code
Always required: dplyr
Word output: flextable
LaTeX output: knitr, optionally kableExtra for enhanced formatting
Robust SE: lmtest, sandwich
Marginal effects: margins
Creates a LaTeX table suitable for PDF documents. Uses booktabs styling and includes significance footnotes via threeparttable package.
format_latex( table, robust.se = FALSE, margins = FALSE, highlight = FALSE, table_size = "normalsize" )format_latex( table, robust.se = FALSE, margins = FALSE, highlight = FALSE, table_size = "normalsize" )
table |
A transformed data frame from transform_table() |
robust.se |
Logical indicating if robust standard errors were used |
margins |
Logical indicating if marginal effects were computed |
highlight |
Logical indicating whether to highlight significant results |
table_size |
LaTeX size command: "tiny", "small", "normalsize", "scriptsize" |
A character string containing the LaTeX table code
Creates a flextable object formatted for Microsoft Word documents. Includes significance footnotes, optional highlighting, and notes about robust standard errors or marginal effects.
format_word(table, robust.se = FALSE, margins = FALSE, highlight = FALSE)format_word(table, robust.se = FALSE, margins = FALSE, highlight = FALSE)
table |
A transformed data frame from transform_table() |
robust.se |
Logical indicating if robust standard errors were used |
margins |
Logical indicating if marginal effects were computed |
highlight |
Logical indicating whether to highlight significant results |
A flextable object ready for export to Word