Summary and Schedule
Chances are that you used R packages before, but did you know you can write your own? Moreover, did you know that this can be a brilliant idea? Packaging helps you creating a more robust, more reproducible, and more enjoyable scientific coding experience. And by contributing a package, you will add to the ever growing capabilities of the R language!
This workshop will provide you with the basics for writing your own packages in R.
R packages are first and foremost a standard way of structuring your work. You have a folder for code, a folder for tests, a folder for data, a folder for documents, and so on. The standardization makes packages easily installable and shareable.
Even if you are not planning to publish your package, structuring your work as one is also a very good idea. It enforces, in a relatively effortless manner, the implementation of software development best practices. This will lead to a safer and more robust working experience, and result in more accurate and reproducible work.
Syllabus
In this lesson you will find episodes on:
- Installing packages
- Setting up your first package
- Testing code
- Adding data to a package
- Managing dependencies
- Writing documentation and vignettes
Prerequisites
In order to follow this lesson you will need to:
- be able to understand simple
R
code, - understand the concept of an
R
function.
In case you are not familiar with these topics, please follow one of our lessons about R.
For a refresher on R functions, head to this episode specifically.
Setup Instructions | Download files required for the lesson | |
Duration: 00h 00m | 1. Introduction |
What is a package? Why do we want a package? ::: |
Duration: 00h 30m | 2. Accessing packages |
How do I use someone else’s package? How do I use my own package? What is the difference between installing and attaching? ::: |
Duration: 01h 15m | 3. Getting started |
“I want to write a package. Where should I start?” ::: |
Duration: 01h 40m | 4. Writing our own functions |
“How can I add functionality to my package?” ::: |
Duration: 02h 10m | 5. Licenses |
How do I allow the use of my package? ::: |
Duration: 02h 35m | 6. Testing |
How can I know that my package works as expected? ::: |
Duration: 04h 05m | 7. Managing dependencies |
How can I make my package as easy to install as possible? ::: |
Duration: 04h 25m | 8. Documenting your package |
How can I make my package understandable and reusable? ::: |
Duration: 05h 25m | 9. Data |
How can I include data in my package? ::: |
Duration: 06h 25m | 10. Vignettes |
I have written the functions in my package, but can I also use
them? How can I write a tutorial or paper as part of my package? ::: |
Duration: 07h 25m | Finish |
The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.
Required software
This lesson assumes you have reasonably up-to-date versions of the following software installed on your computer:
- the R software itself,
- RStudio Desktop,
- Rtools (Windows users only).
Required R packages
You will also need to install the following R packages:
devtools
rmarkdown
roxygen2
They can be installed by executing the code below in your R console:
R
install.packages(c("devtools", "rmarkdown", "roxygen2"))