Rpackages are an interesting way to distribute reproducible papers. You have functions in the
Rdirectory, any required data files in
Descriptionfile that describes the package and all its dependencies, and finally you have the vignette, generally in
inst/doc. Vignettes in
Rtraditionally had to be written in Latex and used Sweave to mix the written and code parts.
It is very easy to imagine that the vignette produced could be a journal article, and therefore to get the reproducible article and access to underlying data and functions, you simply need to install the package. I don't know why I hadn't realized this before. It is actually a really neat, and potentially powerful idea. I would not be surprised that this was actually part of the logic of incorporating the Sweave vignettes in
One wonders why this isn't more common, to distribute papers as packages? I am guessing that it is likely from the requirement to use Latex for writing the document. I've written a vignette, and I can't say I really cared for the experience, basically because getting the Latex part to work was a painful process.
However, with the release of
R 3.0.0, it is now possible to define alternative vignette engines. Currently the only one I know of is
knitr, which currently supports generating PDF from
Rnw(latex with an alternative syntax to Sweave) and HTML from
Rmd, or R markdown files. Markdown is so much easier to write, and in my mind the HTML generated is much easier to read. In addition to that, customization of the look using CSS is probably much more familiar to many people who are doing programming nowadays as well, another big plus.
In addition to having to write using Latex, the process of changing, building, loading, and documenting packages was pretty cumbersome. However, Hadley Wickham has been doing a lot to change that with his
devtoolspackage, that makes it quite easy to re-build a package and load it back up. This has now been integrated into the latest versions of RStudio, making it rather easy to work on a package and immediately work with any changes. In addition, the
test_thatpackage makes it easier to run automated tests, and
ROxygenmakes it easy to also document your custom functions used by your vignette.
So, I know I will be using Yihui's guide to switch my own package to use a markdown vignette, and will probably try to do my next paper as a self contained
Rpackage as well. How about you??
Edit: As Carl pointed out below, pandoc is very useful for converting markdown to other formats that may be required for formal submission to a journal.