Package Development in R

Available Dates

No public dates currently scheduled for this course - new dates coming soon!

If you have a few people interested in this course then Private Courses may a more flexible and cheaper option for you.

If you log in we can let you know when this course is next run.

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.

Introduction to R

Advanced R

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

Course Content

Writing R functions
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.
Starting an R Package
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.
Importing Functions into your 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.
Package Metadata and Documentation
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.
Testing and Installation
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.