R - Vignettes that are not made by Sweave?

Is it possible to add a PDF file to the pkg / doc folder so that the vignette function vignette , but there are no corresponding Rnw, Rtex, etc.?

I think of slides or documents containing markup text composed of R fragments that have a different build process and therefore different file extensions.

The guide to writing R-extensions suggests that it should be possible to include documents that cannot be built during installation, but the vignette function vignette to be looking for files with special extensions (Rnw, Rtex, etc.), as well as for a file named vignette.rds .

Any hints appreciated.

+8
r packaging vignette
source share
3 answers

I asked about this a few years ago, and although Fritz Leish is amenable to this idea, he did not have time to implement it.

+5
source share

(Sent via the answer I just left in R-help :)

As a workaround, you can include your own xvignette function in your package: see below. It will not show you the indexes, but it will pick up any file with the corresponding name that you include in the inst/doc directory of your package ...

 xvignette <- function(vname,pkg,ext="pdf") { vname <- paste(vname,ext,sep=".") fn <- system.file("doc",vname,package=pkg) if (nchar(fn)==0) stop("file not found") utils:::print.vignette(list(pdf=fn)) invisible(fn) } 

You need to somehow warn the users of the package that this alternative documentation exists - perhaps in the help file for the package itself.

You can fill in the default pkg above with your package name to make it easier for the user: I thought about using some option getPackageName(environment(xvignette)) to do it automatically, but it seems too complicated ...

Brian Ripley also mentioned in his answer to the question that:

Vignette () currently stands for Sweave documents, since only they have metadata like names. It is planned to change soon.

... but I don’t know what it means "soon" (it will be about 6 months, until, as it seems to me, 2.14.0 is coming out)

edit : http://article.gmane.org/gmane.comp.lang.r.devel/28449 describes another method in detail (creating a dummy vignette that includes an existing PDF file)

edit 2 : and

+5
source share

It is supported natively as R 3.0.0, see http://yihui.name/knitr/demo/vignette/ .

Instructions for using knitr as a vignette engine knitr down to:

  • add %\VignetteEngine{knitr::knitr} to the source Rnw document (note that you still need %\VignetteIndexEntry{} as before)
  • specify VignetteBuilder: knitr in the DESCRIPTION package
  • add Suggests: knitr to DESCRIPTION if knitr is required only for vignette.

See also the official documentation of the official R documentation on this topic.

+5
source share

All Articles