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 theR/
directory.
Development and Documentation
devtools::load_all()
: Loads all functions in theR/
directory, allowing you to quickly test them without installing the package.devtools::document()
: Generates documentation (.Rd
files in theman/
directory) and theNAMESPACE
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 thetestthat
framework for unit testing.usethis::use_test()
: Creates a new test file intests/testthat/
.devtools::test()
: Runs all the tests in thetests/testthat/
directory.devtools::check()
: Runs the comprehensive suite ofR 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.