R CMD Check and Non-PDF Vignettes

R CMD Check complaining about missing files? Here was my solution.

packages
random-code-snippets
Author

Robert M Flight

Published

October 27, 2021

R CMD Check

If you’ve written an R package that you want hosted by CRAN (or even if not hosted), then you generally want to run the infamous R CMD check on your package.

Although it can be a pain in the butt, it has a wide array of checks that make sense (and some that don’t, just look at posts on the R-devel list).

Missing Files

If you are using rmarkdown to generate non-standard vignettes, or even using rmarkdown because of features that aren’t present directly in knitr, then the check process may fail after it re-builds the package. You may see this message:

Warning: Files in the 'vignettes' directory but no files in 'inst/doc':
  ‘vignette_file.Rmd’

The solution, as far as I can tell, is to:

  • add both knitr and rmarkdown to the Suggests field of DESCRIPTION.
  • add VignetteBuilder: knitr to the DESCRIPTION.
  • add %\VignetteEngine{knitr::rmarkdown} to the vignette meta-data.
  • use output: … whatever actual output document type you wanted in the vignette itself.

I think that the build command only recognizes the knitr engine properly, and that is the only one that builds the vignettes and shoves them in the right location.

Otherwise, you should build them manually and double check the options to build and check so that vignettes don’t get rebuilt during either build or check.

Depending on your needs, you might want to use something like Drew Schmidt’s approach (“Vignette-Less Articles with Pkgdown” 2020).

References

“Vignette-Less Articles with Pkgdown.” 2020. https://fml-fam.github.io/blog/2020/06/23/vignette-less-articles-with-pkgdown/.

Reuse

Citation

BibTeX citation:
@online{mflight2021,
  author = {Robert M Flight},
  title = {R {CMD} {Check} and {Non-PDF} {Vignettes}},
  date = {2021-10-27},
  url = {https://rmflight.github.io/posts/2021-10-27-r-cmd-check-and-non-pdf-vignettes},
  langid = {en}
}
For attribution, please cite this work as:
Robert M Flight. 2021. “R CMD Check and Non-PDF Vignettes.” October 27, 2021. https://rmflight.github.io/posts/2021-10-27-r-cmd-check-and-non-pdf-vignettes.