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

2

6

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.

Southport answered 8/1, 2020 at 12:24 Comment(1)
I'm facing a similar issue, except to throw an additional spanner in the works, I also am getting devtools::build_vignettes() output in the ./docs directory (i.e., root). This is insanity, and after going through so many stack overflow and github threads ― I can only conclude that devtools developers have really stuffed this one up from a user perspective.Parquetry
S
1

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.

Southport answered 11/8, 2020 at 16:20 Comment(0)
R
3

I got this error:

Files in the 'vignettes' directory but no files in 'inst/doc'

upon performing R CMD check, immediately AFTER updating to R 4.0.2 and RStudio 1.3.1056, on two machines (iMac and MacBookPro). In each case it was solved by running devtools::build_vignettes() and pkgdown::build_site(). Here are my notes:

R CMD check error (saw this also on MacBookPro): Files in the 'vignettes' directory but no files in 'inst/doc'

Solved by:

install.packages("devtools")
install.packages("testthat")
devtools::build_vignettes()
install.packages("pkgdown")
library(pkgdown)
pkgdown::build_site()
Rotten answered 10/8, 2020 at 1:44 Comment(0)
S
1

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.

Southport answered 11/8, 2020 at 16:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.