I’ve been working on an R package, R/qtlcharts, with D3-based interactive graphs for quantitative trait locus mapping experiments.
Testing the interactive charts it produces is a bit of a pain. It seems like I pretty much have to just open a series of examples in a web browser and tab through them manually, checking that they look okay, that the interactions seem to work, and that they’re not giving any sort of errors.
But if I want to post the package to CRAN, it seems (from the CRAN policy) that the examples in the .Rd files shouldn’t be opening a web browser. Thus, I need to surround the example code with \dontrun{}.
But I was using those examples, and R CMD check, to open the series of examples for manual checking.
So, what I’ve decided to do:
-
Include examples opening a browser, but within
\dontrun{}so the browser isn’t opened inR CMD check. -
Also include examples that don’t open the browser, within
\dontshow{}, so thatR CMD checkwill at least check the basics. -
Write a ruby script that pulls out all of the examples from the
.Rdfiles, stripping off the\dontrun{}and\dontshow{}and pasting it all into a.Rfile. -
Periodically run
R CMD BATCHon that set of examples, to do the manual checking of the interactive graphs.
This will always be a bit of a pain, but with this approach I can do my manual testing in a straightforward way and still fulfill the CRAN policies.
Update: Hadley Wickham pointed me to \donttest{}, added in R ver 2.7 (in 2008). (More value from blog + twitter!)
So I replaced my \dontrun{} bits with \donttest{}. And I can use devtools::run_examples() to run all of the examples, for my manual checks.