Package 'easytable'

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

Help Index


Create Multi-Format Regression Tables

Description

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.

Usage

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
)

Arguments

...

Statistical model objects (lm or glm). Pass models directly like easytable(m1, m2, m3).

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:

  • "word" - Microsoft Word via flextable (default)

  • "latex" - LaTeX for PDF output

export.word

Character string ending in .docx for Word file export. Only supported when output = "word". If NULL (default), no file is written.

export.csv

Character string ending in .csv for CSV export. If NULL (default), no CSV file is written.

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 output = "latex". Options: "tiny", "small", "normalsize", "scriptsize". Default "normalsize". Error if used with Word output.

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).

Details

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

Value

Depends on output:

  • "word" - A flextable object

  • "latex" - Character string with LaTeX table code

Dependencies

  • Always required: dplyr

  • Word output: flextable

  • LaTeX output: knitr, optionally kableExtra for enhanced formatting

  • Robust SE: lmtest, sandwich

  • Marginal effects: margins


Format table for LaTeX/PDF output

Description

Creates a LaTeX table suitable for PDF documents. Uses booktabs styling and includes significance footnotes via threeparttable package.

Usage

format_latex(
  table,
  robust.se = FALSE,
  margins = FALSE,
  highlight = FALSE,
  table_size = "normalsize"
)

Arguments

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"

Value

A character string containing the LaTeX table code


Format table for Word output

Description

Creates a flextable object formatted for Microsoft Word documents. Includes significance footnotes, optional highlighting, and notes about robust standard errors or marginal effects.

Usage

format_word(table, robust.se = FALSE, margins = FALSE, highlight = FALSE)

Arguments

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

Value

A flextable object ready for export to Word