---
title: "Creating and Maintaining R Packages"
author: "Davide Risso"
date: "22/7/2019"
output: beamer_presentation
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

## Resources

The excellent book _R Packages_ by Hadley Wickham: [r-pkgs.had.co.nz](http://r-pkgs.had.co.nz/)

R Manual - Writing R Extensions: [cran.r-project.org/doc/manuals/r-release/R-exts.html](https://cran.r-project.org/doc/manuals/r-release/R-exts.html)

The `devtools` package

## Steps to create an R package

1. Decide the scope of the package.
2. Collect and clean up all the relevant scripts.
3. Create a new project in R Studio (or use `package.skeleton()` if you don't like R Studio).
4. _Write documentation!_
5. DESCRIPTION and NAMESPACE files (or use `roxygen2`).
6. _Unit tests!_
7. Deploy the package via Github
8. _Maintain the package!_

## Useful tools

- R Studio
- R CMD check
- The `devtools`, `roxygen2` and `testthat` packages
- git and Github
- Continuous Integration (C.I.)

## How to publish your package

http://r-pkgs.had.co.nz/release.html

1. Github (private repo)
2. Github (public repo)
3. CRAN
4. Bioconductor

Which option should I choose?

## CRAN requirements

https://cran.r-project.org/web/packages/policies.html

- R CMD check
- Maintainers has valid email address
- License!
- Works across multiple platforms (Windows, Unix, Mac)

## Bioconductor additional requirements

https://bioconductor.org/developers/package-guidelines/

- R CMD BiocCheck
- Vignette
- Reuse existing Bioconductor infrastructure
- Pass human review
