Testing an R package’s interactive graphs
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.