R package development with devtools, testthat, and roxygen2. Use when the user is working on an R package, running tests, writing documentation, or building package infrastructure.
# Run code in the package
Rscript -e "devtools::load_all(); code"
# Run all tests
Rscript -e "devtools::test()"
# Run all tests for files starting with {name}
Rscript -e "devtools::test(filter = '^{name}')"
# Run all tests for R/{name}.R
Rscript -e "devtools::test_active_file('R/{name}.R')"
# Run a single test "blah" for R/{name}.R
Rscript -e "devtools::test_active_file('R/{name}.R', desc = 'blah')"
# Redocument the package
Rscript -e "devtools::document()"
# Check pkgdown documentation
Rscript -e "pkgdown::check_pkgdown()"
# Check the package with R CMD check
Rscript -e "devtools::check()"
# Format code
air format .
air format . after generating code.|>) not the magrittr pipe (%>%).\() ... for single-line anonymous functions. For all other cases, use function() {...}.R/{name}.R go in tests/testthat/test-{name}.R.expect_true() and expect_false() in favour of a specific expectation which will give a better failure message.expect_error() or expect_warning(). Instead, use expect_snapshot(error = TRUE) for errors and expect_snapshot() for warnings because these allow the user to review the full text of the output._pkgdown.yml.pkgdown::check_pkgdown() to check that all topics are included in the reference index.NEWS.mdNEWS.md. Do not add bullets for small documentation changes or internal refactorings.(#123)..