Writing R Packages

John Fox

McMaster University

GTA R Users Group

23 November 2016, 5:30-7:30 PM

500 University Avenue, Toronto, Room 303/365

Short URL: tinyurl.com/GTAR-packages

Instructions for Installing R, R Studio, and R Packages


I'll use as an example a simple unpublished package called matrixDemos that demonstrates basic concepts in matrix and linear algebra, but you don't have to be conversant with matrix algebra to understand the package-writing process.

script; notes; code: matrixDemos.R; zip file with source-package file tree: matrixDemos.zip; built source package: matrixDemos_1.0-7.tar.gz. I've also created a github repository with the packag sources.


There is, as far as I know, no basic, simple reference on writing R packages.

The Writing R Extensions manual, distributed with R, is the definitive, official reference on constructing R packages, but with the usual limitations of a manual -- it's not really for novices.

Hadley Wickham's book R Packages, Sepastopol CA: O'Reilly, 2015, is (as its name implies) about how to write R packages. Wickham's approach to and tools for constructing R packages are sometimes idiosyncratic but always carefully considered and interesting. You'll have to decide whether or not you want to buy into his approach. The website for the book provides access to the text.