Chapter 3 Building R Packages

This section covers building R packages. Writing good code for data science is only part of the job. In order to maximize the usefulness and reusability of data science software, code must be organized and distributed in a manner that adheres to community-based standards and provides a good user experience. This section covers the primary means by which R software is organized and distributed to others. We cover R package development, writing good documentation and vignettes, writing robust software, cross-platform development, continuous integration tools, and distributing packages via CRAN and GitHub. Learners will produce R packages that satisfy the criteria for submission to CRAN.

The Learning objectives for this section are:

  • Recognize the basic structure and purpose of an R package
  • Create a simple R package skeleton using the devtools package
  • Recognize the key directives in a NAMESPACE file
  • Create R function documentation using roxygen2
  • Create vignettes using knitr and R Markdown
  • Create an R package that contains data (and associated documentation)
  • Create unit tests for an R package using the testthat package
  • Categorize errors in the R CMD check process
  • Recall the principles of open source software
  • Recall two open source licenses
  • Create create a GitHub repository for an R package
  • Create an R package that is tested and deployed on Travis
  • Create an R package that is tested and deployed on Appveyor
  • Recognize characteristics of R packages that are not cross-platform