R Package Developer Essentials

A walkthrough of the various packages, tools, resources, and axioms I have encountered over my years as an R package sofware engineer.

Jimmy Briggs https://devfolio.jimbrig.com
2021-12-18

People who program using the R language can be separated into two core buckets:

  1. R Developers
  2. R Users

To distinguish, R developers develop new innovative solutions while R Users use the tools and packages that the developers created. This article is aimed towards the development side of the spectrum and attempts to provide a comprehensive, curated toolbox for the R Developer, specifically in regard to developing R Packages.

Pre-Requisite Readings

To start, R package developers need to be familiar with the fundamentals of package development, and therefore should be familiar with some of the highest regarded resources available to read.

Anyone who is serious about developing production grade R packages needs to be familiar with most of, if not all of the following resources and guides:

Table 1: R Package Developer Essential Resources
Resource Source
Writing R Extensions CRAN Manuals
R Packages Hadley Wickham
R Package Primer Karl Broman
Package Guidelines Bioconductor
rOpenSci Packages Developer Guide rOpenSci
View Citations

(Wickham and Bryan, n.d.a, n.d.b; “Why Package and Environment Management Is Critical for Serious Data Science,” n.d.a, n.d.b; Vidoni, n.d.; Initiative, n.d.; “An Introduction to Packager,” n.d.; Gandrud 2015; Glennie 2020; “Owen-TheRGuide.pdf,” n.d.; Riederer, n.d.; Spector 2004; Team, n.d.; Zhu and Jianan, n.d.)

Writing R Extensions Manual

The Writing R Extensions Manual is perhaps the most crucial resource listed above, and has even been considered the Bible of R Package Development.

However, it is very exhaustive and not the most visually-appealing write-up.

As Hadley puts it in his book Writing R Packages: (Wickham and Bryan, n.d.c)

“The best resource for the official details of package development is always the official writing R extensions manual. However, this manual can be hard to understand if you’re not already familiar with the basics of packages. It’s also exhaustive, covering every possible package component, rather than focusing on the most common and useful components, as this book does. Writing R extensions is a useful resource once you’ve mastered the basics and want to learn what’s going on under the hood.”

— Hadley Wickham

Thanks to Colin Fay, a more elegant version of the original manual has been created as a bookdown site and published online at https://colinfay.me/writing-r-extensions.

This resource is highly encouraged for anyone taking R Package Development seriously.

Note: The other manuals listed on the CRAN Manuals website contain a lot of hidden gems that are often overlooked by R developers. These resources contain some of the most crucial, foundational knowledge that anyone using R should eventually be made aware of, therefore I highly recommend you check those out in addition to Writing R Extensions.

Package Development Fundamentals

R Package development can be broken down into the following fundamental areas of development:

“An Introduction to Packager.” n.d. https://cran.r-project.org/web/packages/packager/vignettes/An_Introduction_to_packager.html.
Gandrud, Christopher. 2015. Reproducible Research with r and RStudio. Second edition. Chapman & Hall/CRC the r Series. Boca Raton: CRC Press, Taylor & Francis Group.
Glennie, Richard. 2020. “Reproducible Research with r and RStudio by Christopher Gandrud.” Journal of Agricultural, Biological and Environmental Statistics, 12.
Initiative, Environmental Data. n.d. Best Practices for Data Package Design. https://ediorg.github.io/data-package-best-practices/datapackage-design/index.html.
“Owen-TheRGuide.pdf.” n.d. https://cran.r-project.org/doc/contrib/Owen-TheRGuide.pdf.
Riederer, Yihui Xie, Christophe Dervieux, Emily. n.d. R Markdown Cookbook. https://bookdown.org/yihui/rmarkdown-cookbook/.
Spector, Phil. 2004. “An Introduction to r.” University of California, Berkeley. https://www.stat.berkeley.edu/~spector/R.pdf.
Team, R. Core. n.d. Writing r Extensions. https://colinfay.me/writing-r-extensions/index.html.
Vidoni, rOpenSci software review editorial team (current and alumni): Brooke Anderson, Scott Chamberlain, Laura DeCicco, Julia Gustavsen, Jeff Hollister, Anna Krystalli, Mauro Lepore, Lincoln Mullen, Karthik Ram, Emily Riederer, Noam Ross, Maëlle Salmon, Adam Sparks, Melina. n.d. rOpenSci Packages: Development, Maintenance, and Peer Review. https://devguide.ropensci.org/.
“Why Package and Environment Management Is Critical for Serious Data Science.” n.d.a. https://blog.rstudio.com/2020/08/20/why-package-environment-management-is-critical-for-serious-data-science/.
———. n.d.b. https://blog.rstudio.com/2020/08/20/why-package-environment-management-is-critical-for-serious-data-science/.
Wickham, Hadley, and Jennifer Bryan. n.d.c. R Packages. https://r-pkgs.org/.
———. n.d.a. R Packages. https://r-pkgs.org/.
———. n.d.b. R Packages. https://r-pkgs.org/.
Zhu, Yang Feng, and Jianan. n.d. R Programming: Zero to Pro. https://r02pro.github.io/.

References

Corrections

If you see mistakes or want to suggest changes, please create an issue on the source repository.

Citation

For attribution, please cite this work as

Briggs (2021, Dec. 18). Jim's Docs: R Package Developer Essentials. Retrieved from https://jimsdocs.jimbrig.com/posts/2021-12-18-2-r-package-developer-essentials/

BibTeX citation

@misc{briggs2021r,
  author = {Briggs, Jimmy},
  title = {Jim's Docs: R Package Developer Essentials},
  url = {https://jimsdocs.jimbrig.com/posts/2021-12-18-2-r-package-developer-essentials/},
  year = {2021}
}