R package primer a minimal tutorial
R packages are the best way to distribute R code and documentation, and, despite the impression that the official manual (Writing R Extensions) might give, they really are quite simple to create.
You should make an R package even for code that you don’t plan to distribute. You’ll find it is easier to keep track of your own personal R functions if they are in a package. And it’s good to write documentation, even if it’s just for your future self.
But there is value in having a diversity of resources, so I thought I’d go ahead and write my own minimal tutorial. The following list of topics looks forbidding, but each is short and straightforward (and hopefully clear). If you’re put off by the list of topics, and you’ve not already abandoned me in favor of Hadley’s book, then why aren’t you reading Hilary’s tutorial?
If anyone’s still with me, the following pages cover the essentials of making an R package.
- Why write an R package?
- The minimal R package
- Building and installing an R package
- Making it a proper package
- Writing documentation with Roxygen2
- Software licenses
- Checking an R package
The following are important but not essential.
- Putting it on GitHub
- Getting it on CRAN
- Writing vignettes
- Writing tests
- Including datasets
- Connecting to other packages
The following contains links to other resources:
If anything here is confusing (or wrong!), or if I’ve missed important details, please submit an issue, or (even better) fork the GitHub repository for this website, make modifications, and submit a pull request.
The source for this tutorial is on github.