I want to include a pre-compiled PDF as a vignette in a R package. The PDF is not generated via Sweave. Without a .Rnw to process, there is no \VignetteIndexEntry
to cause the usual automatic generation of index.html and Meta/vignette.rds
.
I created an index.html in inst/doc
that is copied into doc
during installation. This is corrected linked from the main package help page. However, when I load the package and execute browseVignettes("MyPackage")
, I get
No vignettes found by browseVignettes("MyPackage")
This makes sense, because R apparently has no way to know that the package has a vignette. The installed package has no Meta/vignette.rds
file. Can I somehow get my PDF to appear with browseVignettes()
?
pdfpages
I'm familiar with the approach taken by the mosaic package, which is to use pdfpages
to include the entire PDF. While clever, I feel like there should be a better way that avoids the proliferation of files.
Right after Yihui....
Make a fake Rnw that looks like this:
%\VignetteIndexEntry{User manual}
\documentclass{article}
\begin{document}
\end{document}
And put it in inst/doc
along side your precompiled vignette and you will be all set.
R definitely needs a better way to deal with vignettes: http://comments.gmane.org/gmane.comp.lang.r.devel/31967 Before my proposal is approved and implemented, we still have to live with the dark voodoo of Makefile. For example, you can put a fake.Rnw
and a real.pdf
under inst/doc
, and mv real.pdf fake.pdf
in the Makefile. In fake.Rnw
, you just follow the rule of \VignetteIndexEntry{}
.
The mosaic
package now apparently uses the R.rsp
package which has an "asis" driver that allows including an existing file and creating the VignetteIndexEntry
. This looks much less like a hack than using pdfpages
or a dummy .Rnw
file (which doesn't seem to work anymore in R 3.1).
Example: For a file V1MinimalR.pdf
, there is a corresponding V1MinimalR.pdf.asis
file with the following contents:
%\VignetteIndexEntry{Minimal R for Intro Stats}
%\VignetteEngine{R.rsp::asis}
The DESCRIPTION
contains (among others) the following:
Suggests: R.rsp
VignetteBuilder: knitr, R.rsp
This is also detailed in this answer by Henrik Bengtsson, the author of the R.rsp package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With