R Package Development Workflow

The Workflow that you may follow while developing your own R package.
R
package
programming
Author

Abdullah Al Mahmud

Published

August 29, 2025

Here are the key devtools functions important in the R package development cycle.

Project Setup

  • usethis::create_package(): Creates a new package with the correct directory structure.
  • usethis::use_git(): Initializes a Git repository for version control.
  • usethis::use_r(): Creates a new .R file in the R/ directory.

Development and Documentation

  • devtools::load_all(): Loads all functions in the R/ directory, allowing you to quickly test them without installing the package.
  • devtools::document(): Generates documentation (.Rd files in the man/ directory) and the NAMESPACE file from roxygen2 comments.
  • devtools::install(): Installs the package from the source directory, making it available for use on your system.

Testing and Checking

  • usethis::use_testthat(): Sets up the testthat framework for unit testing.
  • usethis::use_test(): Creates a new test file in tests/testthat/.
  • devtools::test(): Runs all the tests in the tests/testthat/ directory.
  • devtools::check(): Runs the comprehensive suite of R CMD check tests to identify errors, warnings, and notes.
  • devtools::check_win_devel(): Submits the package to the win-builder service to check for platform-specific issues on Windows.

Publishing

  • usethis::use_vignette(): Creates a new vignette (.Rmd file) for package tutorials.
  • pkgdown::build_site(): Builds a complete website for your package.
  • devtools::submit_cran(): Helps with the final steps of submitting your package to CRAN.