Chapter 5 The package within


To walk through the development of a small toy package, with an emphasis on the package’s R code and how it differs from R code in a script.


  1. Data analysis script
  2. Isolate and extract the reusable data and logic from the script
  3. Put code into an R package
  4. Use package in a newly simplified script.

This chapter purposefully makes mistakes along the way, in order to highlight special considerations for the R code inside a package.

Section headers incorporate the NATO phonetic alphabet.