本文へ移動
cccskills
無料GitHub で公開

gt

R table formatting with gt, kableExtra, modelsummary. Publication-quality tables: gt() grammar-of-tables, fmt_*() formatting, tab_*() structure, gtsave() export. Use when execution language is R. Python equivalent: great-tables (use when execution language is Python).

日本語の概要は準備中です。原文の説明を表示しています。

DAAF-Contribution-Community/daafスター 238(GitHub 238 + cccskills 0)

実行スコア 未検証

インストール方法を見る

含まれるファイル(5)

  • SKILL.md11.8 KB
  • references/export.md6.3 KB
  • references/formatting.md7.7 KB
  • references/modelsummary-tables.md7.8 KB
  • references/quickstart.md4.9 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

gt Skill

R table formatting ecosystem for publication-quality tables. Covers gt 1.3.0 for grammar-of-tables construction (gt(), fmt_() number formatting, tab_() structure, cols_*() column operations, gtsave() export), kableExtra 1.4.0 for knitr/kable HTML and LaTeX table styling in Quarto documents, and modelsummary 2.6.0 for formatting regression output from lm/glm/fixest/plm models into publication tables. Use when execution language is R and the task involves creating formatted data tables, summary tables, or regression tables for reports or papers. Python counterpart: the great-tables skill (same author, same grammar of tables) — use it when execution language is Python. For visualization (charts/plots), use ggplot2 instead. For document structure and rendering, use quarto instead.

What is gt?

gt implements a grammar of tables for R, analogous to ggplot2's grammar of graphics but for tabular output:

  • Declarative: Build tables by layering formatting, structure, and style
  • Pipeline-friendly: Chain operations with |> (data frame in, gt table out)
  • Rich formatting: Number formatting (fmt_number, fmt_percent, fmt_currency), conditional styling, color scales, icons, images in cells
  • Structured: Table header, column spanners, row groups, summary rows, footnotes, source notes
  • Export: HTML, PNG, LaTeX, Word, RTF via gtsave()

kableExtra extends knitr's kable() for HTML and LaTeX table styling:

  • Lightweight alternative when gt is overkill (simple summary tables in Quarto)
  • Row/column styling, striped rows, scroll boxes, grouped rows
  • Tight integration with Quarto's knitr engine

modelsummary formats regression output into publication-ready tables:

  • Supports 100+ model classes (lm, glm, fixest, plm, survey, etc.)
  • Side-by-side model comparison with custom coefficient labels
  • Output to gt, kableExtra, HTML, LaTeX, Word, markdown, PNG
  • Robust/clustered SEs via vcov argument (no re-fitting needed)
  • Already covered in depth by the r-stats skill (reporting.md) and referenced by fixest -- this skill provides the table-formatting perspective

Version Notes

  • gt 1.3.0: Stable release. Full grammar-of-tables API. fmt_*() family for number formatting, tab_*() for structural elements, cols_*() for column operations, opt_*() for table options.
  • kableExtra 1.4.0: Stable release. kbl() replaces knitr::kable() as the recommended entry point. Full HTML and LaTeX styling support.
  • modelsummary 2.6.0: Supports gt and kableExtra as output backends. The default output backend in modelsummary 2.x is tinytable — request a gt object explicitly with output = "gt". See r-stats skill reporting.md for comprehensive modelsummary coverage.
  • knitr 1.51: Provides the underlying kable() function that kableExtra extends.

How to Use This Skill

Reference File Structure

FilePurposeWhen to Read
quickstart.mdBasic gt() table, headers/footers/source notes, simple formattingStarting out or need a quick table
formatting.mdfmt_*() family, conditional styling, spanners, row groups, summary rowsDetailed formatting and structure
modelsummary-tables.mdRegression tables via modelsummary(), customization, multi-model comparisonFormatting regression output
export.mdgtsave(), kableExtra in Quarto, inline tables in .qmd, output formatsSaving or embedding tables

Reading Order

  1. Quick data table? Start with quickstart.md
  2. Complex formatting? Read formatting.md
  3. Regression table? Read modelsummary-tables.md
  4. Saving or embedding? Read export.md
  5. Simple Quarto table? Read export.md (kableExtra section)

Related Skills

SkillRelationship
ggplot2Visualization (charts/plots) -- use ggplot2 for figures, gt for tables
quartoDocument rendering -- gt/kableExtra tables render in .qmd documents
fixestRegression output -- fixest models feed into modelsummary/gt tables. fixest's own etable() is an alternative to modelsummary for fixest-only output
r-statsRegression output -- lm/glm models feed into modelsummary/gt tables. r-stats reporting.md has comprehensive modelsummary coverage
plmPanel model output -- plm models feed into modelsummary/gt tables
data-scientistMethodology guidance for what to present in tables

Python counterpart: Use the great-tables skill for Python table formatting. The great-tables package (version 0.21.0, by the same author as gt, implementing the same grammar of tables) is DAAF's Python table-formatting tool — load that skill when execution language is Python. Note surface differences from gt: method chaining instead of |>, 0-based cols_merge pattern indices, Polars expressions in grand_summary_rows, and HTML/LaTeX export in-process (but no working PNG export in the container). For regression tables in Python, great-tables has no modelsummary equivalent — use pyfixest's etable() or statsmodels' summary().

Quick Decision Trees

"I need to make a table"

What kind of table?
+-- Data summary table (descriptive stats, crosstabs)
|   +-- Simple (few rows/columns, minimal formatting)
|   |   +-- In a Quarto doc? --> kableExtra kbl() in ./references/export.md
|   |   +-- Standalone? --> gt() in ./references/quickstart.md
|   +-- Complex (conditional formatting, row groups, summary rows)
|       +-- gt() in ./references/formatting.md
+-- Regression table (model coefficients)
|   +-- Single model --> ./references/modelsummary-tables.md
|   +-- Multiple models side-by-side --> ./references/modelsummary-tables.md
|   +-- fixest models only --> Consider fixest etable() (see fixest skill)
|       OR modelsummary() for more customization
+-- Frequency / cross-tabulation table
|   +-- gt() with row groups --> ./references/formatting.md
+-- Table with color scales or conditional formatting
    +-- gt tab_style() or data_color() --> ./references/formatting.md

"Which package should I use?"

Choosing a table package?
+-- Publication-quality data table with rich formatting
|   +-- gt() (most flexible, best output quality)
+-- Regression table (multiple models, SEs, goodness-of-fit)
|   +-- modelsummary() (purpose-built for this)
+-- Simple table in a Quarto document
|   +-- kableExtra kbl() (lightweight, integrates with knitr)
+-- Quick console output (not for publication)
|   +-- print() or knitr::kable() (no extra packages needed)
+-- LaTeX table for a journal submission
    +-- gt() with gtsave("file.tex") OR modelsummary(output = "latex")

File-First Execution in Research Workflows

In DAAF research pipelines, tables are generated through script files in scripts/stage8_analysis/, not interactively. This ensures auditability and reproducibility.

The pattern:

  1. Write table code to scripts/stage8_analysis/{step}_{table-name}.R
  2. Execute via bash {BASE_DIR}/scripts/run_with_capture.sh {script_path}
  3. Output gets appended to the script as comments
  4. Use gtsave() to save tables to the project output directory

See agent_reference/SCRIPT_EXECUTION_REFERENCE.md for the mandatory file-first execution protocol.

Quick Reference

Essential Setup

library(gt)
library(kableExtra)
library(modelsummary)

Basic gt Table

tbl <- df |>
  gt() |>
  tab_header(
    title = "Table Title",
    subtitle = "Subtitle or description"
  ) |>
  tab_source_note("Source: Dataset name, year.") |>
  fmt_number(columns = where(is.numeric), decimals = 2)

Core gt Operations

OperationCode
Create tablegt(df) or `df
Title/subtitletab_header(title, subtitle)
Source notetab_source_note("Source: ...")
Footnotetab_footnote(footnote, locations)
Format numbersfmt_number(columns, decimals)
Format percentfmt_percent(columns, decimals)
Format currencyfmt_currency(columns, currency)
Format datefmt_date(columns, date_style)
Column spannertab_spanner(label, columns)
Row groupgt(groupname_col = "group_var")
Summary rowsummary_rows(groups, fns, columns)
Conditional styletab_style(style, locations)
Column labelscols_label(col1 = "Label 1")
Hide columnscols_hide(columns)
Column widthcols_width(col1 ~ px(150))
Savegtsave(tbl, "file.html")

kableExtra Quick Pattern

df |>
  kbl(format = "html", digits = 2, caption = "Table Title") |>
  kable_styling(bootstrap_options = c("striped", "hover", "condensed")) |>
  add_header_above(c(" " = 1, "Group A" = 2, "Group B" = 2))

modelsummary Quick Pattern

modelsummary(
  list("Model 1" = fit1, "Model 2" = fit2),
  stars = c("*" = 0.05, "**" = 0.01, "***" = 0.001),
  coef_rename = c("x1" = "Education", "x2" = "Experience"),
  gof_map = c("nobs", "r.squared", "adj.r.squared"),
  output = "gt"
)

Topic Index

TopicReference File
Basic gt table creation./references/quickstart.md
tab_header, tab_source_note./references/quickstart.md
tab_footnote./references/quickstart.md
Simple number formatting./references/quickstart.md
cols_label column renaming./references/quickstart.md
fmt_number, fmt_percent, fmt_currency./references/formatting.md
fmt_date, fmt_integer./references/formatting.md
Conditional formatting (tab_style)./references/formatting.md
Color scales (data_color)./references/formatting.md
Column spanners (tab_spanner)./references/formatting.md
Row groups./references/formatting.md
Summary rows./references/formatting.md
Grand summary./references/formatting.md
Column width and alignment./references/formatting.md
Merge cells./references/formatting.md
modelsummary basic usage./references/modelsummary-tables.md
Multi-model comparison./references/modelsummary-tables.md
Coefficient renaming and omission./references/modelsummary-tables.md
Custom statistics rows./references/modelsummary-tables.md
Robust/clustered SEs in tables./references/modelsummary-tables.md
fixest models in modelsummary./references/modelsummary-tables.md
Stars and significance formatting./references/modelsummary-tables.md
gtsave to HTML/PNG/LaTeX./references/export.md
kableExtra in Quarto./references/export.md
Inline tables in .qmd./references/export.md
Output format comparison./references/export.md

Citation

When gt is used as a primary table-formatting tool, include in the report's Software & Tools references:

Iannone, R., Cheng, J., Schloerke, B., Hughes, E., Lauer, A., & Seo, J. (2024). gt: Easily Create Presentation-Ready Display Tables. R package version 1.3.0. https://gt.rstudio.com/

Cite when: gt produces tables included in the report or deliverables. Do not cite when: Only used for quick exploratory tables not included in deliverables.

For modelsummary citation (when used for regression tables):

Arel-Bundock, V. (2022). "modelsummary: Data and Model Summaries in R." Journal of Statistical Software, 103(1), 1-23.

For kableExtra citation (when used for Quarto table styling):

Zhu, H. (2024). kableExtra: Construct Complex Table with kable and Pipe Syntax. R package version 1.4.0.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

Guide for creating DAAF agent definition files. Covers 12-section template, hook registration, skills-in-frontmatter, integration checklist. Use when adding or revising agents. For SKILL.md files, use skill-authoring instead.

日本語の概要は準備中です。原文の説明を表示しています。

DAAF-Contribution-Community/daaf2382026年10月17日 更新

Researcher-facing analytic triangulation ("creative verification") for stress-testing provisional findings and designing pre-specified challenges before an analysis runs. Turns a researcher's concern or focal claim into competing explanations, bounded discriminating tests, audited diagnostic artifacts, and evidence-calibrated interpretations in a hypothesis/evidence ledger — behavioral, output-level verification replacing line-by-line code review. Covers 12 challenge families organized by Shadish-Cook-Campbell validity type, named sensitivity statistics, pre-committed interpretation rules, anti-fishing guardrails, and interactive diagnostic-artifact QA. Use in Ad Hoc Collaboration to verify, challenge, or stress-test a result, or to design discriminating tests before an analysis runs. Not code-change verification (verify skill / code review) and not final adjudication or re-execution (data-verifier, Reproducibility Verification) — prospective, hypothesis-driven challenge design of analytic claims.

日本語の概要は準備中です。原文の説明を表示しています。

DAAF-Contribution-Community/daaf2382026年10月17日 更新

In-situ smoke testing that verifies a LIVE DAAF deployment functions end-to-end in whatever provider route it is configured for. Auto-detects the active install route (anthropic-subscription, openrouter, chatgpt-subscription shim, openai-api shim) and runs tiered probes: Tier 0 free preflight (route/env coherence, hooks, statuslines, shim health); Tier 1 one live round-trip (~cents); Tier 2 a six-probe functional battery (dispatch, coding, web, skill loading, isolation-strip, nested-dispatch deny); Tier D a zero-cost deterministic battery (bats, Pester, lint, safety-hook tests). Use after install, after a rebuild or update, after any provider/config change (new API key, model remap, shim change), for pre-release validation, or when asked "is my install working" or to "smoke test the deployment/config." Requires the DAAF_DEV=1 dev image; a contributor tool, not end-user-facing. NOT DAAFBench (model behavioral-adherence evaluation under benchmarks/) and NOT scripts/smoke_tests/ (R/Python library-package smoke tests).

日本語の概要は準備中です。原文の説明を表示しています。

DAAF-Contribution-Community/daaf2382026年10月17日 更新

Operational framework for the DAAF orchestrator. Defines engagement modes, confirmation protocol, subagent dispatch, context budget, and reference-loading. Loaded exclusively by the orchestrator — not for subagents or user questions.

日本語の概要は準備中です。原文の説明を表示しています。

DAAF-Contribution-Community/daaf2382026年10月17日 更新

Data science methodology and method-selection routing for quantitative research. Covers EDA, data validation, descriptive analysis, causal inference (IV, DiD, RD, synthetic control), clustering/PCA/UMAP, supervised ML, geospatial analysis, network analysis, and visualization design. Contains the canonical method-to-library routing tree, routed by execution language — Python: statsmodels (OLS/GLM/time series), pyfixest (FE/DiD), linearmodels (RE/GMM/SUR), svy (complex surveys), scikit-learn (clustering/prediction ML), geopandas (spatial), igraph (network analysis); R: r-stats (OLS/GLM/time series), fixest (FE/DiD), plm (panel/RE/IV), survey-r (complex surveys), tidymodels (ML), sf-terra (spatial), igraph-r (network analysis). Load the routed tool-specific skill before giving tool-specific advice or writing code — library skills encode environment constraints and curated caveats absent from general knowledge.

日本語の概要は準備中です。原文の説明を表示しています。

DAAF-Contribution-Community/daaf2382026年10月17日 更新

Interpretation guidance for Urban Institute Education Data Portal datasets. The Portal is a curation layer over federal data: lowercase variable names, integer-encoded categoricals, standardized missing codes (-1 missing, -2 not applicable, -3 suppressed). Covers year definitions, grade encoding (grade=-1 is Pre-K, not missing), suppression rates, ODC-By licensing, and cross-source join identifiers. Load before analyzing any Portal data. Routes to source-specific deep-dive skills for individual datasets.

日本語の概要は準備中です。原文の説明を表示しています。

DAAF-Contribution-Community/daaf2382026年10月17日 更新

DAAF-Contribution-Community のスキルをすべて見る

このスキルの問題を報告する