This lesson is being piloted (Beta version)

R Packaging

Picture yourself starting a new programming project in R. Most likely, your first step will consist of creating a new folder, a folder that later you’ll populate with files. If the project is long and complex, you’ll need several files and also some subfolders. The folder structure can eventually become pretty complex and difficult to maintain, specially if your project has multiple authors.

Wait a moment! Long and complex projects, multiple authors, … this sounds like any scientific project! Is there a way of making this process easier? The answer is yes, and the way is by structuring our work as a software package.

As we will see, this comes with unexpected advantages: packaging makes your code more robust, more predictable, shareable, easier to read and, most importantly, more enjoyable to write!

This workshop will teach you the first steps in creating your own R package.

Prerequisites

In order to follow this lesson you’ll need:

  • To be able to understand simple R code.
  • To understand the concept of an R function.

In case you are not familiar with the abovementioned topics, please follow first one of our lessons about R.

Additionally, please visit our setup section to make sure you installed all the required software.

Schedule

Setup Download files required for the lesson
00:00 1. Introduction What is a package?
Why do we want a package?
00:30 2. Accessing packages How do I use my package?
How do I use someone else’s package?
What is the difference between installing and attaching?
01:00 3. Getting started I want to write a package. Where should I start?
01:25 4. Writing our own functions How can I add functionality to my package
01:55 5. Licenses How do I allow the use of my package?
02:20 6. Testing How can I know that my package works as expected?
03:50 7. Managing dependencies How can I make my package as easy to install as possible
04:10 8. Documenting your package How can I make my package understandable and reusable?
05:10 9. Data How can I include data in my package?
06:10 10. Vignettes How can I use R packages to write my research?
07:10 Finish

The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.