[Rd] packages with Sweave and knitr vignettes?

Henrik Bengtsson hb at biostat.ucsf.edu
Fri Aug 23 23:49:17 CEST 2013


On Fri, Aug 23, 2013 at 1:24 PM, Michael Friendly <friendly at yorku.ca> wrote:
> Now that R 3.0.0+ supports non-Sweave vignettes, R-exts \S 1.4.2 seems to
> imply that
> it is possible to include both Sweave and knitr vignettes in a single
> package.
>
> I'm wondering
> if anyone has tried this and/or if there are some hidden gotchas putting
> this into practice,
> and concerned about creating problems with CRAN checks if I try this.
>
> Consider two vignettes:
>
> pkg/vignettes/vign1.Rnw, containing:
> % !Rnw weave = Sweave
> %\VignetteEngine{Sweave}
> ...
>
> pkg/vignettes/vign2.Rnw, containing:
> % !Rnw weave = knitr
> %\VignetteEngine{knitr::knitr}
> ...
>
> both are .Rnw files, distinguished only by \VignetteEngine. vign1.Rnw is
> currently in my
> package, and vign2.Rnw compiles OK outside it, using knitr in an R console
> or RStudio.
>
> R-exts implies that the DESCRIPTION file must include (minimally):
>
> VignetteBuilder: Sweave, knitr
> Suggests: knitr

The vignette-builder package for Sweave is 'utils' (not Sweave), so you want:

VignetteBuilder: utils, knitr

However, as said in 'Writing R Extensions', "The utils package is
always implicitly appended to the list of builder packages.", so you
don't really need to add it, but personally I'd say it's a nice
gesture to make it explicit which vignette-builder package you are
using.

Also, the full formal engine name for Sweave is utils::Sweave, so for
complete parallelism with knitr::knitr, you could be explicit and
write \VignetteEngine{utils::Sweave}.

/Henrik

>
> Is anything more/different required?  Does a package exist that does this?
>
> TIA
> -Michael
>
> --
> Michael Friendly     Email: friendly AT yorku DOT ca
> Professor, Psychology Dept. & Chair, Quantitative Methods
> York University      Voice: 416 736-2100 x66249 Fax: 416 736-5814
> 4700 Keele Street    Web:   http://www.datavis.ca
> Toronto, ONT  M3J 1P3 CANADA
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list