4

I am building a new R package. I have the same problem given here. I have also gone through the links suggested. But I keep getting rejections because the note says

"Package has a VignetteBuilder field but no prebuilt vignette index.
So please add a vignette index."

I went to the CRAN package list for latest packages and then went through the code of packages like hyfo , mldr and few others which have all released in the past few days. None of them have an index file. But, my code below is getting rejected. My code does not show any warnings or errors or NOTES when I run devtoold::check(). I am not getting any warnings/errors on devtools:build_win() as well.
Any ideas on what I am missing?

I am using R version 3.2.2 on windows. My DESCRIPTION file which has the following

Package: Mypackage
Suggests:
    knitr,
    rmarkdown,
    R.rsp
VignetteBuilder: knitr
RoxygenNote: 5.0.1

In the vignettes directory, the file Mypackage.Rmd has

title: "Mypackage"
author: "blah"
date: "`r Sys.Date()`"
output:
  html_document:
    fig_width: 7
    fig_height: 6
    fig_caption: true
vignette: >
    %\VignetteIndexEntry{Mypackage}
    %\VignetteEngine{R.rsp::asis}
    %\VignetteEncoding{UTF-8}
---
## Introduction
The contents of the vignette

How do I create the vignette index or how do I make this NOTE disappear?

Community
  • 1
  • 1

1 Answers1

0

Ok 2 issues with this.

Vignette Index

First you need to have a build/vignette.rds file listing the vignettes. You can check this with:

> readRDS("build/vignette.rds")
                File            Title       PDF                          R           Depends         Keywords
1      Mypackage.Rmd        Mypackage       Mypackage.html     Mypackage.R  
2        MyGuide.Rmd        MyGuide         MyGuide.html         MyGuide.R  

Here the "Title" column is the title from \VignetteIndexEntry{Mypackage} and the rest are names of the files.

Notice there 2 additional blank fields "Depends" and "Keywords" here. You can create a new data.frame if you don't have one already.

file <- data.frame(matrix(NA, 1, 6))
colnames(file) <- c("File", "Title", "PDF", "R", "Depends", "Keywords")
file[1,] <- c("MyPackage.Rmd", "MyPackage", "MyPackage.html", "MyPackage.R", "", "")
saveRDS(file, file = "vignette.rds")

To add a row with a new vignette to an existing data.frame:

file <- readRDS("build/vignette.rds")
file[3,] <- c("import_reactome.Rmd", "Importing pathways from databases", "import_reactome.html", "import_reactome.R", "", "")
saveRDS(file, file = "vignette.rds")

Generating static HTML vignettes

These vignettes are not generated on CRAN and must be pre-generated before upload. Run knitr::knit in RStudio on an Rmd file is the easiest way to do this. Then copy the output file to vignettes/MyPackage.html. You can also skip building vignettes by copying it to inst/doc/MyPackage.html.

You can add this line to return an HTML file when building the package.

title: "Mypackage"
author: "blah"
date: "`r Sys.Date()`"
output:
  html_document:
    fig_width: 7
    fig_height: 6
    fig_caption: true
    keep_html: true       ### <- add this line
vignette: >
    %\VignetteIndexEntry{Mypackage}
    %\VignetteEngine{R.rsp::asis}
    %\VignetteEncoding{UTF-8}
---

You do not need a markdown file. You can add the following line to .Rbuildignore to prevent it being included.

^vignettes/plot_directed.md#

Passing checks with devtools

For more details see the Static_PDF_and_HTML_vignette from R.rsp. This describes how to use the R.rsp::asis engine.

The key part is that you need to have both a vignettes/MyPackage.html and vignettes/MyPackage.html.asis file. The vignettes/MyPackage.html.asis file only needs 3 lines, the rest are optional.

%\VignetteIndexEntry{MyPackage}
%\VignetteEngine{R.rsp::asis}
%\VignetteEncoding{UTF-8}

Once these files are included the devtools::install(build_vignettes = TRUE) and devtools::check() should run as expected.

Tom Kelly
  • 1,458
  • 17
  • 25