/r-package-skills:r-flextablefrom r-package-skills
Creates publication-quality tables in R using flextable, with output to Word, PowerPoint, HTML, and PDF. Handles cell merging, conditional formatting, and cross-format consistency.
Ships in r-package-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
flextable creates publication-quality tables that render consistently across Word, PowerPoint, HTML, and PDF.
Core principle: Separate data from display. Build from a data.frame, then layer formatting declaratively using selectors.
Read references/API.md before writing code.
references/API.md - Complete function referencereferences/overview.md - Core concepts and workflowreferences/formatting.md - Styling and appearancereferences/layout.md - Structure and mergingreferences/selectors.md - Targeting cells for formattingreferences/output.md - Rendering to different formatsUse flextable when:
Consider alternatives:
| Task | Function |
|---|---|
| Create table | flextable(df) |
| Format numbers | colformat_double(), colformat_int() |
| Bold/italic/color | bold(), italic(), color() |
| Background color | bg() |
| Merge cells | merge_v(), merge_h(), merge_at() |
| Add header | add_header_row() |
| Auto-size | autofit() |
| Apply theme | theme_vanilla(), theme_zebra() |
| Save to Word | save_as_docx() |
| Save to PowerPoint | save_as_pptx() |
library(flextable)
# Create -> format -> output
ft <- flextable(head(mtcars, 5)) |>
colformat_double(digits = 1) |>
# Conditional formatting with formula selectors
color(i = ~ mpg > 20, j = "mpg", color = "darkgreen") |>
bold(i = ~ mpg > 20, j = "mpg") |>
# Spanning header
add_header_row(
values = c("Performance", "Engine", "Transmission"),
colwidths = c(2, 4, 5)
) |>
theme_vanilla() |>
autofit()
save_as_docx(ft, path = "table.docx")
Target cells for formatting:
# Row selector (formula)
bold(ft, i = ~ cyl == 6)
# Column selector
bg(ft, j = ~ mpg + hp, bg = "lightgray")
# Part selector
bold(ft, part = "header")
See references/selectors.md for details on multi-content cells, mini charts, output-specific notes.
| Mistake | Fix |
|---|---|
| Theme doesn't format new header | Apply theme AFTER add_header_row() |
autofit() overflows margins | Use set_table_properties(layout = "autofit") |
height() has no effect | Set hrule(rule = "exact") first |
| Formula selectors fail in header | Use integer indices for header rows |
| Images missing in Word | Use officedown::rdocx_document() |
| PDF ignores padding | Use ft.tabcolsep chunk option |
add_header_row values wrong | One value per span; colwidths sum to ncol |
See references/ for:
references/API.md (opens in a new tab)references/advanced.md (opens in a new tab)references/crosstabs.md (opens in a new tab)references/formatting.md (opens in a new tab)references/layout.md (opens in a new tab)references/output.md (opens in a new tab)references/overview.md (opens in a new tab)references/selectors.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
14 skills in this plugin
/r-aiUse when code loads ellmer, btw, mcptools, ragnar, or vitals, building LLM-powered R applications, implementing RAG workflows, or choosing between R AI packages (meta-skill for ellmer/btw/mcptools/ragnar/vitals)/r-btwUse when code loads or uses btw (library(btw), btw::), providing R session context to LLMs, registering tools for ellmer chat, or copying R object descriptions to clipboard/r-collapseUse when code loads or uses collapse (library(collapse), collapse::), performing fast grouped or weighted statistics in R, or seeking faster alternatives to dplyr aggregation/r-duckplyrUse when code loads or uses duckplyr (library(duckplyr), duckplyr::), processing large datasets with dplyr syntax, working with Parquet files in R, or needing lazy evaluation for bigger-than-memory data/r-duckspatialUse when code loads or uses duckspatial (library(duckspatial), duckspatial::), performing spatial joins or areal interpolation on large vector datasets in R, or needing faster spatial operations than sf/r-ellmerUse when code loads or uses ellmer (library(ellmer), chat_openai, chat_claude, chat_ollama), chatting with LLMs from R, building chatbots, or extracting structured data from text with LLMsnpx claudepluginhub arthurgailes/r-package-skills --plugin r-package-skillsOther plugins' skills for the same job