๐ฆ Workshop 2: Package Your Code
โTurn your R scripts into shareable, installable, and testable tools.โ
โ Level UP your Code! โ Workshop 2
๐ฏ Workshop Goal
Learn how to transform your R code into a proper R package so that it can be reused, installed, tested, and shared easily.
๐ง Key Concepts
- ๐ Understand package structure:
DESCRIPTION
,NAMESPACE
,R/
- โ๏ธ Automate setup with
usethis
- ๐งช Document functions with
roxygen2
- ๐งช Test code using built-in testing structure
- ๐งฉ Build and install packages locally or via GitHub
โ๏ธ Tools Youโll Use
๐งฐ Starter Resources
- ๐งช GitHub Template Repository: rpackage-template
๐ ๏ธ Quick Workflow
# Set up your package structure
usethis::create_package("mypackage")
# Add and document a function
usethis::use_r("myfunction")
usethis::use_roxygen_md()
devtools::document()
# Add tests
usethis::use_testthat()
usethis::use_test("myfunction")
# Install locally
devtools::install()
โญ๏ธ Next Workshop : GitHub โ Save & Deploy Your Code