gt Table Formatting Cheat Sheet
An R gt reference for table objects, column selection, headers, numeric and date formatting, styles, footnotes and export workflows.
What this reference covers
The gt reference follows a data frame into a structured report table. It covers table objects, titles and subtitles, column labels, spanner headers, numeric and date formats, conditional styling, footnotes and output for different media.
Separate data work from presentation
Complete filtering, summarizing and sorting before formatting. Then use column selectors to express labels, units, precision and emphasis. Keeping the stages separate makes it easier to prove that a visual change did not alter a value or statistical definition.
Validate selectors and output dimensions
A selector can match a different set of columns after a field is renamed or a new field is added. Check selected names and types after each rule, then inspect long labels, footnotes, widths and pagination in the real web, report or print container.
Maintenance note
gt does not infer the correct denominator, unit or analysis method. Preserve the data version, generation code and output date with important tables. Content review date: 2026-08-23.
Save to your cloud drive
Save the complete collection first so files remain together and are easier to access across devices.
Quark Cloud Drive
RecommendedSave gt Table Formatting Cheat Sheet to this cloud drive
Baidu Netdisk
Save gt Table Formatting Cheat Sheet to this cloud drive
gt table formatting study guide
Build the table structure from verified data, apply column-aware formatting and styling last, then review the exported table at its actual size.
Before you start
- Prepare a PDF reader and a data frame with clear column names and units.
- Choose the target medium: web page, report, print or image.
- Know which columns are numeric, dates, categories and missing-value fields.
Quick start
- 01
Create the base table
Confirm row grain, sorting and values before creating the table object, and keep statistical transformations outside the layout stage.
- 02
Set headers and labels
Add title, subtitle, column labels and grouped headers in an order that follows the data meaning and reader path.
- 03
Format by column type
Handle integers, decimals, percentages, dates and missing values separately, checking selector ranges before applying a rule.
- 04
Style and export last
Add emphasis, notes, sources and borders after the structure is correct, then inspect width, wrapping and pagination in the target medium.
Usage tips
- Keep data transformations and table formatting separate so each can be validated independently.
- Review selector matches after columns are added, renamed or recast.
- Use notes for statistical definitions, abbreviations, missing values and rounding.
Troubleshooting and uninstall
Why did a format rule affect the wrong columns?
Inspect column names, types and selector matches on a minimal table, then expand the rule to the full result.
Why does the table overflow on a web page?
Shorten labels, adjust column order and width, remove decorative columns and review the layout at the real container width.
Frequently asked questions
What workflows does the gt cheat sheet cover?
It covers table objects, headers, column labels, spanners, numeric and date formats, styles, footnotes and export.
Why separate data processing from formatting?
The separation lets you validate source data and statistical meaning independently from the final display.
What is the risk of column selectors?
Renamed, added or recast fields can change which columns match, so selector results should be checked after each rule.
How can an exported table be checked?
Review width, long labels, notes, pagination, contrast and numeric precision in the actual output medium rather than only in a preview.