Skip to content

[Cheat Sheet] Building the package

Charlotta edited this page Oct 8, 2020 · 3 revisions

We are using devtools, usethis and pkgdown to build the package and create (hopefully meaningful) documentation.

If you are not familiar with the R packages, at least the following commands will be useful for contributing code, building and checking the package

Creating a new function

# Create empty R file to define function
usethis::use_r()

# Matching R testthis file where your unit tests should live
usethis::use_test()

After making changes and before committing, check the build using R CMD check:

devtools::check()

Install the package locally:

Simulate installing without actually installing the current version of the package

devtools::load_all()

Actually install the package

devtools::install()

Load installed version package

library(visR)

Build the page incl. documentation:

pkgdown::build_site()


More can be found in Hadley's book on R packages: https://r-pkgs.org/

About the packages that we use to help with our development workflow:

  • devtools provides R functions that simplify and expedite common tasks and make package development easier.
  • usethis is a workflow package: it automates repetitive tasks that arise during project setup and development.
  • pkgdown is designed to make it quick and easy to build a website for your package.