Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking R package vignettes

Tags:

Is there any way I can include links between package vignettes in R? I know I can link between section, for example

# Section 1 {#section1} My first section  # Section 2 A link to [Section 1](#section1) 

But is there any way I can get a clickable link that will launch the HTML doucment of another vignette? Or is it just easier to give the code to launch it?

```r vignette("my vignette", package = "myPackage") ``` 

Note I have generated all of my vignettes using Rmarkdown and knitr.

like image 256
nathaneastwood Avatar asked Jan 22 '16 11:01

nathaneastwood


People also ask

How do I add a vignette to a package in R?

To create a package vignette in R Markdown, the easiest way is through the RStudio menu File -> New File -> R Markdown -> From Template (see Figure 16.4). Then you select “Package Vignette” from the rmarkdown package, and you will get a vignette template.

What is an R package vignette?

A vignette is like a book chapter or an academic paper: it can describe the problem that your package is designed to solve, and then show the reader how to solve it. Many existing packages have vignettes.

How do I get vignettes in R?

You can discover vignettes by accessing the help page for a package, or via the browseVignettes() function: the command browseVignettes() opens a list of vignettes from all of your installed packages in your browser, while browseVignettes(package=package-name) (e.g., browseVignettes(package="survival") ) shows the ...

What is Knitr package?

The R package knitr is a general-purpose literate programming engine, with lightweight API's designed to give users full control of the output without heavy coding work. It combines many features into one package with slight tweaks motivated from my everyday use of Sweave.


1 Answers

Yes, this is simple. Vignettes are all stored in the same directory, so you simply refer to the appropriate file name. The drat package vignettes have several examples of this. Here is a link from one vignette to the other:

This vignette deals with the first case: How to use [drat](http://dirk.eddelbuettel.com/code/drat.html) as a package author.  A [companion vignette for package users](DratForPackageUsers.html) is available as well. 

This will work on CRAN and on a user's machine.

You should also be able to link from vignettes to documentation, and vice versa, on a user's machine, knowing that vignettes are stored in library/PKGNAME/doc/ and documentation is stored in: library/PKGNAME/html/.

like image 76
Thomas Avatar answered Sep 27 '22 22:09

Thomas