How to scaffold a proper R package
使うタイミング: You're tired of hand-writing DESCRIPTION, NAMESPACE, and roxygen2 boilerplate.
前提条件
- Skill installed — git clone https://github.com/posit-dev/skills ~/.claude/skills/posit-skills
- R + devtools — install.packages('devtools')
フロー
-
ScaffoldUse Posit R-package skill. Create a new package 'tidylaundry' with 2 exported functions: wash() and fold().✓ コピーしました→ Directory with DESCRIPTION, NAMESPACE, R/, tests/testthat/, README
-
Add roxygenAdd roxygen2 docs with @param, @return, @examples for each function.✓ コピーしました→ Inline docs that devtools::document() converts to man/
-
Smoke testWrite testthat tests covering happy path + one edge case each.✓ コピーしました→ Tests passing under devtools::test()
結果: A package that passes R CMD check on day one.
注意点
- Generated code uses base R where tidyverse would be clearer (or vice versa) — State the style preference upfront