build-parameterized-report
关于
This skill enables developers to create parameterized Quarto or R Markdown reports that generate multiple variations from a single template. It covers defining parameters, programmatic rendering, and batch generation for automated workflows. Use it for producing department-specific reports, client-customized outputs, or automating recurring reports with different inputs.
快速安装
Claude Code
推荐npx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/build-parameterized-report在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
建參報
造受參之報,自一模生多客變。
用
- 為異部、域、期生同報
- 自模造客專報
- 建濾於具子之儀
- 自定期報附異入
入
- 必:報模(Quarto 或 R Markdown)
- 必:參定(名、類、默)
- 可:批生之參值列
- 可:生報之出目
行
一:YAML 定參
Quarto(report.qmd):
---
title: "Sales Report: `r params$region`"
params:
region: "North America"
year: 2025
include_forecast: true
format:
html:
toc: true
---
R Markdown(report.Rmd):
---
title: "Sales Report"
params:
region: "North America"
year: 2025
include_forecast: true
output: html_document
---
得: YAML 頭含 params: 塊附名參,各有正類默值。
敗: 渲敗報「object 'params' not found」→確 params: 塊於 YAML 首縮對。Quarto params 必於 YAML 頂,非 format: 下嵌。
二:碼中用參
```{r}
#| label: filter-data
data <- full_dataset |>
filter(region == params$region, year == params$year)
nrow(data)
```
## Overview for `r params$region`
This report covers the `r params$region` region for `r params$year`.
```{r}
#| label: forecast
#| eval: !expr params$include_forecast
# This chunk only runs when include_forecast is TRUE
forecast_model <- forecast::auto.arima(data$sales)
forecast::autoplot(forecast_model)
```
得: 碼塊以 params$name 引參,條塊以 Quarto #| eval: !expr params$flag。行內 R 表如 `r params$region` 渲動文。
敗: params$name 返 NULL→驗參名於 YAML 與碼全合(區大小)。察默值類正。
三:以客參渲
單渲:
# Quarto
quarto::quarto_render(
"report.qmd",
execute_params = list(region = "Europe", year = 2025)
)
# R Markdown
rmarkdown::render(
"report.Rmd",
params = list(region = "Europe", year = 2025),
output_file = "report-europe-2025.html"
)
得: 單報以客參值成渲,覆 YAML 默。出檔於所述徑造。
敗: Quarto 渲敗→察 quarto CLI 已裝且於 PATH。R Markdown 敗→驗 rmarkdown 已裝。確參名於 execute_params(Quarto)或 params(R Markdown)合 YAML 定。
四:批渲多報
regions <- c("North America", "Europe", "Asia Pacific", "Latin America")
years <- c(2024, 2025)
# Generate all combinations
combinations <- expand.grid(region = regions, year = years, stringsAsFactors = FALSE)
# Render each
purrr::pwalk(combinations, function(region, year) {
output_name <- sprintf("report-%s-%d.html",
tolower(gsub(" ", "-", region)), year)
quarto::quarto_render(
"report.qmd",
execute_params = list(region = region, year = year),
output_file = output_name
)
})
得: 每域年組一 HTML。
敗: 察參名於 YAML 與碼全合。確諸參值有效。
五:加參驗
#| label: validate-params
stopifnot(
"Region must be a valid region" = params$region %in% valid_regions,
"Year must be numeric" = is.numeric(params$year),
"Year must be reasonable" = params$year >= 2020 && params$year <= 2030
)
得: 驗碼塊於每渲始行,若參出範或類誤則以清誤止。
敗: stopifnot() 生無益訊→換顯 if (!cond) stop("message") 呼以清診。
六:組出
# Create output directory
output_dir <- file.path("reports", format(Sys.Date(), "%Y-%m"))
dir.create(output_dir, recursive = TRUE, showWarnings = FALSE)
# Render with output path
quarto::quarto_render(
"report.qmd",
execute_params = list(region = region),
output_file = file.path(output_dir, paste0("report-", region, ".html"))
)
得: 出檔書於日戳子目附述名(如 reports/2025-06/report-europe.html)。
敗: dir.create() 敗→察父目存且可書。Windows 上驗徑長不過 260 字。
驗
- 報以默參渲
- 報以每組客參渲
- 參處前驗
- 出檔命述
- 條段依參正渲
- 批生於諸組完
忌
- 參名不合:YAML 名必全合碼
params$name引 - 類強轉:YAML 或解
year: 2025為整,而碼候字元。必顯。 - 條評:Quarto 用
#| eval: !expr params$flag,非eval = params$flag - 檔覆:無唯出名→每渲覆前
- 批記:久批或積記。宜用
callr::r()為隔。
參
create-quarto-report— 基 Quarto 文設generate-statistical-tables— 適參之表format-apa-report— 參化學術報
GitHub 仓库
相关推荐技能
content-collections
元Content Collections 是一个 TypeScript 优先的构建工具,可将本地 Markdown/MDX 文件转换为类型安全的数据集合。它专为构建博客、文档站和内容密集型 Vite+React 应用而设计,提供基于 Zod 的自动模式验证。该工具涵盖从 Vite 插件配置、MDX 编译到生产环境部署的完整工作流。
polymarket
元这个Claude Skill为开发者提供完整的Polymarket预测市场开发支持,涵盖API调用、交易执行和市场数据分析。关键特性包括实时WebSocket数据流,可监控实时交易、订单和市场动态。开发者可用它构建预测市场应用、实施交易策略并集成实时市场预测功能。
creating-opencode-plugins
元该Skill帮助开发者创建OpenCode插件,用于接入命令、文件、LSP等25+种事件。它提供了插件结构、事件API规范和JavaScript/TypeScript实现模式,适合需要拦截操作、扩展功能或自定义事件处理的场景。开发者可通过它快速构建响应式模块来增强OpenCode AI助手的能力。
sglang
元SGLang是一个专为LLM设计的高性能推理框架,特别适用于需要结构化输出的场景。它通过RadixAttention前缀缓存技术,在处理JSON、正则表达式、工具调用等具有重复前缀的复杂工作流时,能实现极速生成。如果你正在构建智能体或多轮对话系统,并追求远超vLLM的推理性能,SGLang是理想选择。
