/lang-r:r-developmentfrom lang-r
Provides expert guidance for R package development using devtools, testthat, and roxygen2. Covers workflow, testing patterns, documentation standards, and code quality.
Ships in lang-r. 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.
None: SKILL.md is the whole skill.
Use this skill when working with R packages to ensure proper development workflows, testing patterns, and documentation standards.
# Load package for interactive development
devtools::load_all()
# Update documentation (REQUIRED before committing R changes)
devtools::document()
# Run all tests
devtools::test()
# Run specific test file
testthat::test_file("tests/testthat/test-filename.R")
# Run tests matching a pattern
devtools::test(filter = "pattern")
testthat::test_local(filter = "pattern")
# Check package (R CMD check)
devtools::check()
# Build package
devtools::build()
# Install package locally
devtools::install()
# Check with vignettes built
devtools::check(build_args = c("--compact-vignettes=both"))
# Lint package (configuration in .lintr)
lintr::lint_package()
# Lint specific file
lintr::lint("R/filename.R")
# Style code (pre-commit hook typically uses tidyverse style)
styler::style_pkg()
# Check test coverage
covr::package_coverage()
# Build vignettes
devtools::build_vignettes()
# Build specific vignette
rmarkdown::render("vignettes/name.Rmd")
# Build pkgdown site locally
pkgdown::build_site()
Preferred expectations:
expect_identical() > expect_equal() (when exact match expected)expect_true() calls > stacking conditions with &&expect_s3_class() > expect_true(inherits(...))expect_* functions:
expect_lt(), expect_gt(), expect_lte(), expect_gte()expect_length()expect_named()expect_type()Examples:
# Good
expect_identical(result, expected)
expect_s3_class(obj, "data.frame")
expect_lt(value, 10)
expect_true(condition1)
expect_true(condition2)
# Avoid
expect_equal(result, expected) # when identical match is needed
expect_true(inherits(obj, "data.frame"))
expect_true(value < 10)
expect_true(condition1 && condition2)
test-{component}.Rtests/testthat/helper-{name}.Rtests/testthat/setup.R for shared fixturestests/testthat/helper-expectations.R# Skip tests on CRAN
testthat::skip_on_cran()
# Skip if not on CI
testthat::skip_if_not(on_ci())
# Skip if package not available
testthat::skip_if_not_installed("package")
Avoid duplication with @inheritParams:
#' @param x Input data
#' @param ... Additional arguments
my_function <- function(x, ...) {}
#' @inheritParams my_function
#' @param y Another parameter
wrapper_function <- function(x, y, ...) {}
Documentation structure:
@family tags for related functions@examples or @examplesIf for examplesExample documentation:
#' Process input data
#'
#' This function processes the input data according to specified parameters.
#' It returns a processed data frame with additional columns.
#'
#' @param data A data.frame containing the input data
#' @param method Character string specifying the processing method
#'
#' @return A data.frame with processed results
#'
#' @family preprocessing
#'
#' @examples
#' \dontrun{
#' result <- process_data(my_data, method = "standard")
#' }
#'
#' @export
process_data <- function(data, method = "standard") {
# implementation
}
Internal functions: Prefix with .
.internal_helper <- function() {}
Exported functions: Use snake_case
public_function <- function() {}
Typical .pre-commit-config.yaml includes:
style-files: Auto-format R codelintr: Lint R codereadme-rmd-rendered: Ensure README.md is up-to-dateparsable-R: Check R syntaxdeps-in-desc: Check dependencies are in DESCRIPTION# Install pre-commit
pip install pre-commit
# Install hooks
pre-commit install
# Run manually
pre-commit run --all-files
Many R packages use data.table for performance:
data.table objectsdata.table::setDT() or custom coerce_dt() to ensure input is data.tabledata.table::setkey(dt, col):= for in-place modificationinherits() or expect_s3_class()# Use specific package functions with ::
package::function()
# Add to DESCRIPTION Imports or Suggests
usethis::use_package("package_name")
usethis::use_package("package_name", type = "Suggests")
Activate this skill when:
This skill provides R-specific development patterns. Project-specific architecture and domain knowledge should remain in project CLAUDE.md files.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
r-package-development, devtools, testthat, roxygen2, r-testing, r-documentation
2 skills in this plugin
2 plugins ship this exact skill · first indexed Aug 16, 2026
npx claudepluginhub bquilty25/bq-skills --plugin lang-rOther plugins' skills for the same job