r-package-dev

Convert R statistical functions into documented, tested packages with roxygen2 and testthat.

33|6|Updated Mar 17, 2026
One-click install
npx skills add https://github.com/xjtulyc/awesome-rosetta-skills --skill r-package-dev-xjtulyc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: r-package-dev
Source: https://github.com/xjtulyc/awesome-rosetta-skills/tree/main/skills/23-research-workflow/r-package-dev
Command: npx skills add https://github.com/xjtulyc/awesome-rosetta-skills --skill r-package-dev-xjtulyc

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps you turn research methods written in R into a reusable, well-tested, properly documented package that can be built and submitted to CRAN or Bioconductor with confidence.

Core Features & Use Cases

  • Scaffold a research-ready R package using a standard structure (DESCRIPTION, NAMESPACE, R/ source, man/ docs, tests/, vignettes/, inst/ data).
  • Generate documentation with roxygen2 so function documentation stays consistent with the codebase, including parameter docs and examples.
  • Ensure correctness with testthat by adding unit tests and running them during development and CI.
  • Support distribution workflows including R CMD check, CRAN submission readiness, and vignette creation to demonstrate statistical methods.
  • Optional Python interoperability by interfacing with R packages via rpy2 for workflows where experiments and analysis span Python and R.

Quick Start

Ask an AI agent to scaffold an R package named mystatpack with roxygen2 documentation, testthat unit tests for compute_effect_size and power_analysis, and a vignette that demonstrates how to use the package for effect size computation and sample size planning.

Frequently Asked Questions about r-package-dev

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create an R package ready for CRAN submission from my custom statistical functions?

To create a CRAN-ready R package, you need to scaffold a standard structure with DESCRIPTION and NAMESPACE files, document APIs using roxygen2, validate behavior with testthat unit tests, and pass R CMD check. This process converts statistical functions into a maintainable, distributable package.

How does roxygen2 documentation work when developing an R package?

Roxygen2 documentation generates standard R manual files directly from inline code comments. It keeps function documentation consistent with the codebase by extracting parameter descriptions and examples, eliminating the need to maintain separate help files manually during package development.

What's the best way to add unit tests to an R package using testthat?

The best way to add unit tests with testthat is to create a tests/ directory within your R package structure. You write test scripts validating function behavior, which can then be automatically executed during development and continuous integration to ensure code correctness.

Can I interface my R package with Python for cross-language statistical analysis?

Yes, you can interface R packages with Python for cross-language analysis using rpy2. This optional interoperability allows workflows where experiments and statistical analysis span both Python and R environments within the same package ecosystem.

How do I generate vignettes to demonstrate statistical methods in an R package?

To generate vignettes for an R package, you create documents within the vignettes/ directory that demonstrate your statistical methods. These provide worked examples and experimental demonstrations, helping users understand how to apply your package's functions effectively.

Do I need a standard R package layout to submit to Bioconductor?

Yes, submitting to Bioconductor or CRAN requires a standard R package layout including R/ source, man/ docs, DESCRIPTION, and NAMESPACE files. Proper structuring with roxygen2 and testthat ensures the package meets repository checks and readiness standards.