AER Table Formatting
Rewrite R table-producing scripts to output AER-compliant LaTeX tables with PDF preview.
Constraints
- •NEVER change table content: which variables, statistics, columns, or samples are reported.
- •CAN change R packages and formatting code.
- •MUST preserve all analysis/estimation code upstream of the table.
- •MUST ensure all required packages are loaded (
library()calls).
Workflow
- •Read the user's R script completely.
- •Identify table type using the detection table below.
- •Identify content: variables, statistics, models, labels, notes, panels.
- •Rewrite formatting using templates from
references/r-code-patterns.md. - •Apply rules from
references/aer-style-guide.md. - •Output .tex file via
save_tt()oretable(..., file=). - •Add PDF preview using
preview_tex()helper fromreferences/r-code-patterns.md. - •Verify all required
library()calls are present.
Table Type Detection
| Signal | Type | Package |
|---|---|---|
feols() / feglm() / fepois() models | Regression | fixest::etable + style.tex("aer") |
lm() / glm() / felm() / plm() / other models | Regression | modelsummary + tinytable |
| Mean / SD / min / max / quantile summaries | Summary stats | modelsummary::datasummary + tinytable |
| Treatment vs. control group comparison | Balance table | modelsummary::datasummary_balance + tinytable |
| Manual data frame → table | Custom | tinytable::tt() |
Quick Reference
- •Rules: Three horizontal lines only (top, header-sep, bottom). No vertical lines.
- •Stars:
*10%,**5%,***1% — on coefficients only, never on SEs. - •SEs: In parentheses, line below coefficient. Type stated in notes.
- •Decimals: Coefficients/SEs/R² = 3; N = integer with commas.
- •Labels: Readable English. Interactions:
$\times$. Logs: prefixLog. - •Headers: Model numbers
(1),(2), etc. Dep var as spanning header. - •Notes: Below bottom rule,
\footnotesize. "Notes:" italic, then SE type, stars, source. - •Output:
.texfile + standalone PDF preview viapreview_tex().