R package workshop
Preface
About this workshop
This workshop was created by COMBINE, an association for Australian students in bioinformatics, computational biology and related fields. You can find out more about COMBINE at http://combine.org.au.
The goal of this workshop is to explain the basics of R package development. By the end of the workshop you should have your own minimal R package that you can use to store your personal functions.
The materials were written using the bookdown package (https://bookdown.org/home/), which is built on top of R Markdown and knitr.
Requirements
The workshop assumes that you are familar with basic R and the RStudio IDE. This includes topics such as installing packages, assigning variables and writing functions. If you are not comfortable with these you may need to complete an introductory R workshop first.
R and RStudio
You will need a recent version of R and RStudio. These materials were written using R version 3.6.0 (2019-04-26) and RStudio version 1.2.1335. You can download R from https://cloud.r-project.org/ and RStudio from https://www.rstudio.com/products/rstudio/download/.
Packages
The main packages used in the workshop are below with the versions used in these materials:
- devtools (v2.1.0)
- usethis (v1.5.1)
- roxygen2 (v6.1.1)
- testthat (v2.2.1)
- knitr (v1.24)
- ggplot2 (v3.2.1)
- rlang (v0.4.0)
Please make sure these packages are installed before starting the workshop. You can install them by running the following code.
Build tools
Some stages of the package development process can require other programs to be installed on your computer. To check that you have everything you need run the following function in R (after installing the packages above).
This function will check if you have the build tools installed and prompt you to install them if you don’t.
GitHub
Version control using git is very useful and should be part of your package development process but it is outside the scope of this workshop. However, uploading your package to code sharing websites such as GitHub is the easiest way to distribute it. Towards the end of the workshop is a section showing you to upload your package to GitHub using R commands (no knowledge of git necessary). If you would like to try this and don’t already have a GitHub account please create one at https://github.com/join.
License
These materials are covered by the Creative Commons Attribution 4.0 International (CC BY 4.0) license (https://creativecommons.org/licenses/by/4.0/).