UPDATE 2014-06-08: For a better solution to including static PDFs and HTML files in an R package, see my other answer in this thread on how to use R.rsp (>= 0.19.0) and its R.rsp::asis
vignette engine.
All you need is a <name>.Rnw
file with a name matching your static <name>.pdf
file, e.g.
vignettes/
static.pdf
static.Rnw
where <name>.Rnw
(here static.Rnw
) is a minimal valid Sweave file, e.g.
%\VignetteIndexEntry{<title to be displayed on the R vignette index page>}
\documentclass{article}
\begin{document}
\end{document}
This vignette source file (<name>.Rnw
) tricks R CMD build
to build it, i.e. R's tools::buildVignettes()
will first Sweave <name>.Rnw
into <name>.tex
as usual. However, due to how buildVignettes()
is designed it will detect our static <name>.pdf
file as already being created by the Sweave engine and therefore it will not compile that dummy TeX file into a PDF file (which would overwrite our static file).
What is important to understand is that (i) vignettes are "build" during R CMD build
, (ii) and when built they are copied over to the inst/doc/
directory (created if missing) of the built package. Also, (iii) the vignettes/
directory will not be part of the build package, i.e. <pkgname>_<version>.tar.gz
file. So, make sure to look in inst/doc/
.
So, to be clear here, using a dummy <name>.Rnw
could be considered a hack that may break if someone decides to prevent against this strategy. However, if that happens, it is fully possible to create a non-Sweave vignette engine which sole purpose is to compile a <name>.pdf
file into a ... <name>.pdf
file. This is valid and possible due to the non-Sweave support added in R (>= 3.0.0). I've been considering adding such engine to the R.rsp package, e.g. \VignetteEngine{R.rsp::StaticPDF}. With that you would not even have to have that dummy Rnw file - only the PDF file.
Hope this helps
vignettes/
with even stricter enforcement in the future. – Lisbethlisbon