[R-pkg-devel] What is the proper way to include README.Rmd generated png’s for package submission to CRAN?

Tim Appelhans tim.appelhans at gmail.com
Mon May 22 07:49:23 CEST 2017

I don't know if this is the proper way but if you host your package on 
github what you can do is add the image you want to be displayed in a 
'inst' or 'docs' (in case you use pkgdown) folder push to github and 
then include a link to that image in README.md. This is how we do this 
in mapview


which shows up fine on CRAN too




On 22.05.2017 03:48, Sebastian Kopf wrote:
> Hi all,
> I’m stuck trying to figure out the appropriate way to include figures
> generated by a README.Rmd for package submission to CRAN. Any advice much
> appreciated. Here is the problem:
>   - I generated an RMarkdown package README using
> `devtools::use_readme_rmd()`, leaving the chunk options intact (i.e.
> `fig.path=‘README-‘`)
>   - I included basic instructions and links to the vignettes but would also
> like to include an example figure so I added a chunk in the README.Rmd that
> generates and correctly saves the resulting figure in README-example-1.png
>   - The package passes `devtools::check(cran = TRUE)` without errors,
> warnings or notes but generates a warning on win-builder because of the
> figure with the following message:
> *Conversion of 'README.md' failed:pandoc.exe: Could not fetch
> README-example-1.pngREADME-example-1.png: openBinaryFile: does not exist
> (No such file or directory) *
> I understand that this is correct behavior because the file is of course
> explicitly excluded from the build (`^README-.*\.png$` in .Rbuildignore),
> and without this line in .Rbuildignore I would get a different warning that
> this png should indeed not be part of the build.
> What I could not figure out is how I should proceed with this so it passes
> win_builder.
> I checked how this is done in the ggplot2 GitHub repository (which also
> includes a figure in its README.md that is generated by a README.Rmd) and
> made sure my .Rbuildignore and other settings are all correct. I eventually
> realized that the README.html generated on CRAN for ggplot2 actually does
> not have the png included either (
> https://cran.r-project.org/web/packages/ggplot2/README.html) so perhaps
> this is just not possible and I need to communicate to win_builder that it
> will indeed be missing this png in some way? Or perhaps I should just avoid
> having an example figure in the README altogether?
> Any help much appreciated, I apologize if this turns out to be a trivial
> question and there is some different way I should be generating the README
> for submission to CRAN.
> Best regards,
> Sebastian
> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-package-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

Tim Appelhans
Research Specialist, Geomarketing
GfK | Bamberger Str. 6, 90425 Nürnberg | Germany
Postal address: Nordwestring 101 | 90419 Nürnberg

More information about the R-package-devel mailing list