NOTE or WARNING from a package check when README.md contains images

I have a package with README.Rmd that I pass to rmarkdown::render() creating README.md and the README_files directory that contains the images in README.md . It looks like a tree below.

README_files not a standard package directory , so if it is not in .Rbuildignore , check the package with the R CMD check shows a note:

* checking top-level files ... NOTE Non-standard file/directory found at top level: README_files

But including the directory in .Rbuildignore leads to a warning, if and only when checking the package --as-cran . IIUC Pandoc is trying to generate HTML from README.md , but images are not available in the ignored README_files directory.

 Conversion of 'README.md' failed: pandoc: Could not fetch README_files/unnamed-chunk-14-1.png README_files/unnamed-chunk-14-1.png: openBinaryFile: does not exist (No such file or directory) 

Is there a way to get a clean --as-cran here?

├── README_files │ └── figure-markdown_github │ ├── unnamed-chunk-14-1.png │ ├── unnamed-chunk-15-1.png │ ├── unnamed-chunk-16-1.png │ ├── unnamed-chunk-26-1.png │ └── unnamed-chunk-27-1.png ├── README.md ├── README.Rmd

+7
r r-markdown pandoc
source share
3 answers

There are several options.

  • Store the image on the Internet somewhere and provide the URL in README.
  • As @Axeman noted, you can follow ggplot2's approach to storing images at the top level and mention them in .Rbuildignore .
  • You can save them in inst/image and use png::readPNG(system.file("image/yourpic.png", package = "yourpkg")) to read it. Then show it in README using the graph.
+4
source share

The current preferred solution (at least used by ggplot2 ) is to save the images in man/figures/ . Therefore, in the README.Rmd file README.Rmd enter something like the following installation fragment.

 ```{r, echo = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-" ) ``` 

This saves images hidden in a place that will not generate crane validation errors, but they are still part of the package. Therefore, you do not need to store them in another place or use png::readPNG .

+5
source share

I followed http://r-pkgs.had.co.nz/release.html . same error when placing at the top level and adding to .Rbuildignore.

As Richie suggested, adding images to inst / image and called ![](inst/image/README-unnamed-chunk-1-1.png)

+2
source share

All Articles