SKILL·DC6F4E

write-roxygen-docs

pjt222
Updated 1 month ago
20 views
21
3
21
View on GitHub
Metaworddata

About

This Claude Skill generates roxygen2 documentation for R package components including functions, datasets, and classes. It follows tidyverse style, handles standard tags and cross-references, and creates proper NAMESPACE entries. Use it when documenting new exports, internal helpers, S3/S4/R6 methods, or fixing R CMD check documentation issues.

Quick Install

Claude Code

Recommended
Primary
npx skills add pjt222/agent-almanac -a claude-code
Plugin CommandAlternative
/plugin add https://github.com/pjt222/agent-almanac
Git CloneAlternative
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/write-roxygen-docs

Copy and paste this command in Claude Code to install this skill

Documentation

書 Roxygen 文

立 R 包函、數、類之全 roxygen2 文。

  • 為新出函加文→用
  • 錄內輔函→用
  • 錄包數→用
  • 錄 S3/S4/R6 類與法→用
  • 修文相關 R CMD check 註→用

  • :欲錄之 R 函、數、類
  • :交參之關函(@family@seealso
  • :函是否出

一:書函文

置 roxygen 註於函上:

#' Compute the weighted mean of a numeric vector
#'
#' Calculates the arithmetic mean of `x` weighted by `w`. Missing values
#' in either `x` or `w` are handled according to the `na.rm` parameter.
#'
#' @param x A numeric vector of values.
#' @param w A numeric vector of weights, same length as `x`.
#' @param na.rm Logical. Should missing values be removed? Default `FALSE`.
#'
#' @return A single numeric value representing the weighted mean.
#'
#' @examples
#' weighted_mean(1:5, rep(1, 5))
#' weighted_mean(c(1, 2, NA, 4), c(1, 1, 1, 1), na.rm = TRUE)
#'
#' @export
#' @family summary functions
#' @seealso [stats::weighted.mean()] for the base R equivalent
weighted_mean <- function(x, w, na.rm = FALSE) {
  # implementation
}

得:完 roxygen 塊含題、述、各參之 @param@return@examples@export

敗:標不確→察 ?roxygen2::rd_roclet。常漏為 @return,CRAN 對諸出函要。

二:要標參

出函必?
#' Title首行、一句
#' Description空行後段
@param參文
@return返值述是(CRAN)
@examples用例強薦
@export加 NAMESPACE是,公 API
@family關函組
@seealso交參
@keywords internal標內為非出文

得:函型須標皆辨。出函至少有 @param@return@examples@export

敗:標未識→參 roxygen2 文 之用與法。

三:錄數

R/data.R

#' Example dataset of city temperatures
#'
#' A dataset containing daily temperature readings for major cities.
#'
#' @format A data frame with 365 rows and 4 variables:
#' \describe{
#'   \item{date}{Date of observation}
#'   \item{city}{City name}
#'   \item{temp_c}{Temperature in Celsius}
#'   \item{humidity}{Relative humidity percentage}
#' }
#' @source \url{https://example.com/data}
"city_temperatures"

得:R/data.R 含每數之 roxygen 塊附述構之 @format 與述源之 @source

敗:R CMD check 警未錄數→確引串(如 "city_temperatures")精配 usethis::use_data() 存物名。

四:錄包

R/packagename-package.R

#' @keywords internal
"_PACKAGE"

## usethis namespace: start
## usethis namespace: end
NULL

得:R/packagename-package.R 存附 @keywords internal"_PACKAGE" 標。devtools::document()man/packagename-package.Rd

敗:R CMD check 報缺包文→驗檔名為 R/<packagename>-package.R 且含 "_PACKAGE" 串。

五:應特例

含點函(S3 法):

#' @export
#' @rdname process
process.myclass <- function(x, ...) {
  # S3 method
}

復用文@inheritParams

#' @inheritParams weighted_mean
#' @param trim Fraction of observations to trim.
trimmed_mean <- function(x, w, na.rm = FALSE, trim = 0.1) {
  # implementation
}

無見綁修.data 代詞:

#' @importFrom rlang .data
my_function <- function(df) {
  dplyr::filter(df, .data$column > 5)
}

得:特例(S3 法、繼參、.data 代詞)正錄。@rdname 組 S3 法。@inheritParams 復用參文無重。

敗:R CMD check 警「no visible binding for global variable」→加 #' @importFrom rlang .data 或末計用 utils::globalVariables()

六:生文

devtools::document()

得:man/ 目更附每錄物之 .Rd 檔。NAMESPACE 重生附正出與入。

敗:察 roxygen 法誤。常疾:\describe{} 中括未閉、行缺 #' 前綴、無效標名。修後再行 devtools::document()

  • 每出函有 @param@return@examples
  • devtools::document() 行無誤
  • devtools::check() 無文警
  • @family 標正組關函
  • 例行無誤(以 devtools::run_examples() 試)

  • @return:CRAN 要諸出函錄返值
  • 例需網/認:以 \dontrun{} 包附註釋以何
  • 慢例:CRAN 過長之有效例用 \donttest{}
  • roxygen 中 markdown:DESCRIPTION 中啟 Roxygen: list(markdown = TRUE)
  • 忘行 devtools::document():man 頁為生、非手書

  • create-r-package - 包設始含 roxygen 配
  • write-testthat-tests - 試所錄函
  • write-vignette - 函參之外長文
  • submit-to-cran - CRAN 之文要

GitHub Repository

pjt222/agent-almanac
Path: i18n/wenyan-ultra/skills/write-roxygen-docs
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams
FAQ

Frequently asked questions

What is the write-roxygen-docs skill?

write-roxygen-docs is a Claude Skill by pjt222. Skills package instructions and resources that Claude loads on demand, so Claude can perform write-roxygen-docs-related tasks without extra prompting.

How do I install write-roxygen-docs?

Use the install commands on this page: add write-roxygen-docs to Claude Code as a plugin, or clone its repository into your skills directory, then restart Claude so it picks up the skill.

What category does write-roxygen-docs belong to?

write-roxygen-docs is in the Meta category, tagged word and data.

Is write-roxygen-docs free to use?

Yes. write-roxygen-docs is listed on AIMCP and free to install. It runs inside Claude, so no separate service account is required to use the skill itself.

Related Skills

content-collections
Meta

This skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.

View skill
polymarket
Meta

This skill enables developers to build applications with the Polymarket prediction markets platform, including API integration for trading and market data. It also provides real-time data streaming via WebSocket to monitor live trades and market activity. Use it for implementing trading strategies or creating tools that process live market updates.

View skill
creating-opencode-plugins
Meta

This skill helps developers create OpenCode plugins that hook into 25+ event types like commands, files, and LSP operations. It provides the plugin structure, event API specifications, and implementation patterns for JavaScript/TypeScript modules. Use it when you need to intercept, monitor, or extend the OpenCode AI assistant's lifecycle with custom event-driven logic.

View skill
sglang
Meta

SGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.

View skill