Cannot add a vignette to an R package

416 Views Asked by At

Could you please help me?

I'm building an R package for the final assignment of Coursera's Building R Packages.

So far, I've followed all steps to add a vignette described in the courses's readings, chapter 16.7 of R Markdown Cookbook, and chapter 11 of R Packages, which are basically:

First, add a vignette with:

usethis::use_vignette("mypackage")

Second, edit the YAML heading of the RMD file created in the directory vignettes.

Third, edit the content of the vignette.

However, after installing and loading the package, the vignette cannot be found using the command:

browseVignettes("mypackage")

I get this error:

No vignettes found by browseVignettes("mypackage")

My package is already available in this GitHub repo, if you want to take a look at the files.

What is missing, please? Thanks!

1

There are 1 best solutions below

1
Marco On

Meanwhile, I found the solution here: How to Add a Vignette to a Package in RStudio

It all boils down to installing the package from its source file instead of installing it directly from the package's directory.

As explained in the link provided above, the vignette is only built this way:

Open your package's project file (.Rproj) in RStudio;

Go to Build>Build Source Package;

Close the project and RStudio;

Go to Tools>Install Packages;

In Install From, select Package Archive File;

In Package Archive, browse for the source file (.tar.gz).

Click on Install;

In RStudio's console, look for the vignette with:

browseVignettes("mypackage")