[R-pkg-devel] Best practices for vignettes

Dirk Eddelbuettel edd at debian.org
Sun Jul 26 21:22:53 CEST 2015


On 26 July 2015 at 18:42, Lenth, Russell V wrote:
| What's the best way to manage vignettes?

All the young ones will of course tell you to use Markdown :)

I still use Sweave / LaTeX as well, along with a custom driver: highlight, as
we once figured out how to make it create pretty shaded boxen with code (as
seen in the various Rcpp vignettes).

So for that I often keep a five-line script 'buildVignette.r' in the vignette
directory.  With DESCRIPTION set up right (for the added vignette driver)
this then works in the package when it works manually for the tests.

And during the R CMD build ... ; R CMD INSTALL ... steps the vignette does
get rebuild.

Oh, but did I mention that markdown is easier?  ;-)   Earlier this year I
converted to writing my LateX Beamer presentation in RMarkdown (which
rmarkdown::render() then converts to LaTeX). I may, time permitting, look
into converting vignetts.  But why mess with a working setup...

Dirk


PS buildVignette.r from an older package I am currently working on

#!/usr/bin/Rscript

## use given argument(s) as target files, or else default to .Rnw files in directory
files <- if (length(commandArgs(TRUE)) == 0) dir(pattern="*.Rnw") else commandArgs(TRUE)

## convert all files from Rnw to pdf using the highlight driver
invisible(sapply(files, function(srcfile) {
    Sweave(srcfile, driver=highlight::HighlightWeaveLatex(boxes=TRUE))
    tools::texi2pdf(gsub(".Rnw", ".tex", srcfile))
}))


-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org



More information about the R-package-devel mailing list