Training

Take this course

Schedule an on-site training at your location, or suggest a public workshop.

Schedule on-site training Suggest a public workshop

Overview

In this course you’ll learn an efficient package development workflow developed by Hadley Wickham, the author of over 30 R packages including ggplot2, plyr, and devtools.

Main concepts:

  • Transform existing R code into packages that others can easily download and use
  • Learn a fluid package development process facilitated by the devtools package
  • Write inline documentation with roxygen2
  • Develop automated tests with the testthat package to ensure that your code is correct today, and continues to be correct in the future
  • Recognize common errors that prevent you from passing R CMD check
  • Release your package into the wild, through the official CRAN repository for worldwide distribution, or to local repositories for controlled distribution

What will you learn?

How to develop an idea into a published, stable R package. Through a series of demonstrations and hands on exercises, you will learn to use advanced R features to quickly build, document, test, and publish R packages.

Introduction to R packages - Packages are one of the most useful tools in the R programming language. You can use packages to quickly solve problems not easily handled by base R. You can also share your own code with friends, coworkers, or even the global R community by building it into a package.

  • How to structure an R package
  • Working with libraries and installing packages
  • The package development cycle

Documentation and namespaces - Two things must happen before your code can become useful. First, other programmers must be able to understand your code. Second, R must be able to integrate your new functions with pre-existing ones. We will show you how to take care of these by documenting your package and creating a package namespace for your functions.

  • Documenting your packages and functions
  • Formatting text in help pages
  • Exporting functions to a package namespace
  • Use functions from other packages in your own package

Code testing - Maintaining an R package requires advanced planning. You can simplify debugging, quickly spot unintended consequences, and generally ensure that your package is stable by creating thoughtful unit tests.

  • Make code maintenance easier with unit tests
  • Quickly create unit tests for your package with testthat
  • Seamlessly integrate unit testing into your workflow with devtools

Releasing your package - The R Core Development team helps developers share their packages with the world by hosting packages along with R on the CRAN repository. You’ll learn how to ensure your package meets R Core’s high quality standards for packages and how to best market your package after it has been included.

  • Using and passing R CMD check
  • Submitting a package to CRAN
  • Marketing your package after its release
  • Simplifying package development with source code control

Who should take this course?

This class will be a good fit for you if you’ve developed some code that you now want to distribute to others. We’ll get you up to speed with everything you need to know about packages.

Not ready for this? Consider taking Intro to data science with R or Advanced R programming.

What's included?

All participants who register for Package development will receive lifetime access to all the slides, exercises, data sets, and R scripts used in the course.

What should I bring?

You need your laptop and the latest version of R. Obviously we recommend the RStudio IDE, but it's not required: bring the R environment that makes you the most productive.

Take this course

Schedule an on-site training at your location, or suggest a public workshop.

Schedule on-site training Suggest a public workshop