Package Development in R

Available Dates

Course Location Starting Date
Package Development in R Online 02 March 2026 View

An R package is one of the simplest ways to write reusable code which can be used across projects or shared with others. This course shows you how to take functions you have developed and put them into the framework of an R package.

It further shows how to write more robust functions including dependencies, error handling and the use of test suites to ensure code integrity.

By the end of the course you should be able to write and distribute your own packages

Pre-Course Requirements & Suggestions

This course assumes that you have knowledge or skills equivalent to those taught in the following courses.

Advanced R (with tidyverse)

Please ask us if you're unsure if you have the necessary knowledge or skills for this course.

Course Content

(click to expand each section)

We begin by going through how to write functions in R and the best practices which will make them more robust. We also go through how to check for problems in input data and provide useful feedback to the user of the function.
We go through the suite of helper packages which will make the creating of a new package easier. We mostly use the devtools package but supplement this with roxgen2 for documentation, testthat for test suites and knitr for vignettes. We create a package repository in github and create the basic structure for your new package.
Once you have the basic package structure you can transfer over the functions you have previously written. We go through the modifications you need to make to put functions into packages and show how to express dependencies so that they are handled automatically.
We look at other pieces of information contained within your package. We discuss how to version your package, how to select a suitable licence for redistribution and how to add documentation.
To finish the course we go through how to write a test suite to ensure that the functions work correctly, and to detect any regressions from future modifications. We also show how you can allow others to install your package.