rpackagevignette

How to properly organise vignettes and inst folders when creating new R package


Before asking I accept that many parts of this question have been touched upon in other stack over and I have read the Hadley Wickham inst and vignette sections but I am still struggling to fix my warnings. Apologies if this question is a bit long winded, I will try to be thorough.

My issue concerns my package_tutorial.

The first warning I am getting is:

> checking files in ‘vignettes’ ... WARNING
  Files in the 'vignettes' directory but no files in 'inst/doc':
  ‘package_tutorial.Rmd’, ‘package_tutorial.pdf’

In Hadley Wickham's documentation it states "inst/docs: This is an older convention for vignettes, and should be avoided in modern packages." So why is CMD check asking for the vignettes to be in the inst/doc folder? I will outline what is in the vignette and inst folder near the end of the quetion.

The next warning I get follows suit:

> checking package vignettes in ‘inst/doc’ ... WARNING
  dir.exists(dir) is not TRUE
  Package vignette without corresponding single PDF/HTML:
     ‘package_tutorial.Rmd’

I do not have a doc folder because it was made clear that the inst/doc folder is obsolete. When I do the CMD check with my vignette in a inst/doc folder the doc folder is deleted. I understand this may be part of the re-building process.

Additional information which may help resolve this issue:

Folder construction (only for vignette and inst folders):

package - inst - extdata - package_tutorial.pdf

package - inst - extdata - package_tutorial.Rmd

package - inst - extdata - plots - several plots which the vignette uses

package - vignettes - package_tutorial.pdf

package - vignettes - package_tutorial.Rmd

I have played around with different options of not having Rmd files in the extdata and not having pdf files in the vignettes folder but alas this has not solved the issue.

YAML metadata:

---
title: "package tutorial"
author: "Krutik Patel"
output:
        pdf_document: 
                keep_tex: true
                toc: true
                toc_depth: 5
                fig_width: 5
                fig_heigh: 4
                fig_caption: true
                df_print: kable 
                highlight: tango
                citation_package: natbib
vignette: >
        %\VignetteIndexEntry{package tutorial}
        %\VignetteEngine{knitr::rmarkdown}
        \usepackage[utf8]{inputenc}

Build tools options: Build and Reload - R CMD INSTALL additional options:

--no-multiarch --with-keep.source --resave-data

Check Package - R CMD INSTALL additional options:

--as-cran --no-build-vignettes

Build Source Package - R CMD INSTALL additional options:

--compact-vignettes="both"

I do hope this is enough information to help me with my question. I am hoping it is something silly which I have just not seen. Any help of guidance is most appreciated.


Solution

  • This is a bit late but, the error went as soon as I stopped saving my built vignettes within the R package.

    Instead I only have the rmd file and associated plots in the /vignette folder and have an /inst folder which does not contain any vignette associated material.