8

I'm trying to see the vignette that I've created after rebuilding a package on my local computer. Note that this has nothing to do with suggestions on this post, since I'm not cloning from Github.

The vignettes portion of my vignette file looks like this:

vignette: >
  %\VignetteIndexEntry{pack_name}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}

The process is:

  1. Ctr + Shift + K to knit the vignette

  2. Ctr + Shift + B to rebuild the package

  3. Enter browseVignettes("package name")

Get error: No vignettes found by browseVignettes

I also tried changing knitr::markdown to knitr::knitr, but it didn't help.

Entire vignette top-portion:

---
title: "Random title"
author: "Author"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{vignette_name}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---
matsuo_basho
  • 2,833
  • 8
  • 26
  • 47

1 Answers1

10

You don't give all the details to say what went wrong, but here is what you need to do:

  1. Vignettes need to be in the package vignettes directory.
  2. If they are anything but Sweave vignettes (and yours is knitr::rmarkdown, according to the header lines you showed us), then you need to tell R about it in the DESCRIPTION file. For your example, you'd need VignetteBuilder: knitr in that file, and also have knitr listed in the Suggests, Depends, or Imports lines.
  3. You need to follow the naming convention for your vignette engine. For knitr::rmarkdown, name the file something.Rmd.
  4. You don't need to knit the file yourself. R will do that when it builds the source package. (You can configure RStudio to do this for "Install and Restart"; by default it doesn't.) Even if you haven't knitted the vignette, browseVignettes should find it if you've followed the other steps properly, it just won't display the HTML or PDF output, only the source and extracted R code.

Edited to add: When building and reinstalling the package, it appears that sometimes vignettes aren't included unless the install is done from a .tar.gz file. Use the "Build Source Package" option in the RStudio build pane to get one of those.

user2554330
  • 37,248
  • 4
  • 43
  • 90
  • 1. This was the case already 2. This was also the case already (for both conditions you listed) 3. Added .Rmd to the package name in VignetteIndexEntry ........ Still the same error message. – matsuo_basho Mar 25 '18 at 18:26
  • For 3, the index entry doesn't matter, it's the filename. If you're on Windows, be careful that you don't get a name like `something.Rmd.txt`, with the `.txt` hidden. knitr won't recognize that as a vignette. If that isn't it, I think you'll have to post the whole vignette (or a usable subset) for people to check. – user2554330 Mar 25 '18 at 18:30
  • It is saved as an .Rmd file. I added the whole vignette metadata section to my original post – matsuo_basho Mar 25 '18 at 18:36
  • 1
    I saw the same problem as you did when I ran "Install and Restart", but things were fine when I built a source package and installed that. I'm sure both worked earlier on a different package; not sure what's special about this one. – user2554330 Mar 25 '18 at 18:51
  • 1
    When you say build source package, are you referring to 'Build & Reload'? – matsuo_basho Mar 25 '18 at 18:54
  • 2
    No. Go to the Build pane, then in the "More" dropdown, choose "Build Source Package". This will create a file with extension .tar.gz, which you can distribute to others. You install it using "Packages | Install | Install from... | Package Archive file". – user2554330 Mar 25 '18 at 19:10
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/167523/discussion-between-user2554330-and-matsuo-basho). – user2554330 Mar 25 '18 at 21:45
  • hi, i'm having the same problem as @matsuo_basho. when I choose "build source package" i get the error `Error in process_initialize(self, private, command, args, stdout, stderr, : object 'c_callr_exec' not found` – maja zaloznik Apr 04 '18 at 18:09