[Rd] packages with Sweave and knitr vignettes?

Yihui Xie xie at yihui.name
Sat Aug 24 05:20:59 CEST 2013


Note there is a bug in R-release, and its consequence is that you
cannot use two different weave engines on two documents of the same
file extension.  In your case, you cannot use both knitr and Sweave on
two .Rnw documents. I just checked R-devel, and it has not been fixed
yet. If you do not have a good reason to use both engines, you can
just choose one of them.

Other than that, I think the non-Sweave vignettes are in a pretty good
state now.

You can check the Reverse Suggests on CRAN:
http://cran.r-project.org/package=knitr Most of them suggested knitr
for vignette building purposes, and knitr itself also uses knitr to
build LaTeX, HTML, and Markdown vignettes.

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Web: http://yihui.name
Department of Statistics, Iowa State University
102 Snedecor Hall, Ames, IA


On Fri, Aug 23, 2013 at 4:49 PM, Henrik Bengtsson <hb at biostat.ucsf.edu> wrote:
> 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



More information about the R-devel mailing list