How to precompute package vignettes or pkgdown articles

As of earlier this year, we are now automatically building binaries and pkgdown documentation for all rOpenSci packages. One issue we encountered is that some packages include vignettes that require some special tools/data/credentials, which are unavailable on generic build servers.

This post explains how to include such vignettes and articles in your package:


Thanks for the article, @jeroenooms. I’ve already done this with GSODR and nasapower and have an updated version of the bomrang vignette waiting for the next release.

It’s a super-handy way to handle internet connectivity and/or long execution times in vignettes.

1 Like

Interesting idea. I use a similar approach:
Pre-compute a model and save the output object (e.g., out, saved in out.rdata or so), then in markdown display the original code, but don’t run it (eval=F,include=T), and in actuality load the ‘out.rdata’ file, but don’t display it (eval=T,echo=F).
The problem with that is that if it’s MCMC draws, the out.rdata file takes up a lot of space, and you don’t really want to upload that to github or bitbucket.

Nice article @jeroenooms, it is maybe worth mentioning to clean up and add the precompile.R and the *.Rmd.orig files to .Rbuildignore.

Thanks @jeroenooms for a nice article, a small addition - you can also run purl next to knit to have the vignette’s R code accessible to the users, like in a “normal” vignette:

knitr::purl("vignettes/longexample.Rmd.orig", output = "vignettes/longexample.R")