Introduction


  • “An R package is a project in a standardized folder structure”
  • “An R package centers around R functions”
  • “RStudio is a useful editor that helps you package your project”

Accessing packages


  • To use a package you have to install and attach it
  • To use a homemade package, you also have to build it
  • The build, install and attach process is usually automated by RStudio
  • There are several ways of installing a package
  • The best way of installing packages is dependent on the developer and user needs

Getting started


  • “A package is no more and no less than a folder structure”
  • “RStudio can help you”

Writing our own functions


  • “It is important to think about what we want our package to do (design) and how will it do it (implementation). We also want to know why we need a new package (avoid reinventing the wheel)”
  • “Functions have to be saved in .R files in the R folder”

Licenses


  • A license is essential to allow the use and reuse of your package.
  • The copyright holder(s) decide(s) on the license.
  • It is easy to add an open source license to a new R package.

Testing


  • Tests help you write a reliable package
  • A failing test provides a lot of valuable information
  • Checking goes deeper than testing

Managing dependencies


  • The DESCRIPTION file helps us keep track of our package’s dependencies

Documenting your package


  • Documentation is not optional
  • All coding projects need a readme file
  • roxygen2 helps us with the otherwise tedious process of documenting
  • roxygen2 also takes care of NAMESPACE

Data


  • R packages can also include data

Vignettes


  • Reports can be part of the package