I am currently building a package for a rather specific audience. The package itself is coming along nicely but I am having trouble getting my README.Rmd to convert to a README.md (using devtools::build_readme()
. Some functions in my package output ggplot
objects and these render to GitHub README fine. However, other functions output flextable
objects, which are inherently HTML and which GitHub does not like to display.
I was hoping that build_readme()
would use {webshot2}
to take a snapshot of my tables for use in non-HTML formats, such as github_document
but this doesn't seem to be the case. I do have {webshot2}
installed and Google Chrome is my primary browser so I have that. My README displays fine on my documentation page (since it's an HTML page).
Is there something I'm missing with build_readme()
or {webshot2}
? Or is this really something that isn't possible right now and I should direct all users to my documentation's copy of the README rather than the GitHub version?
Thank you in advance for your help.
I don't see a simple way to do this, but
flextable
supports saving a table to a PNG file, and you could do that and then include the file usingknitr::include_graphics()
.For example, your first example could be modified to look like this:
It's probably best to only print
flextable
objects in a chunk that usesrender = flextable_to_image
because theelse
clause is overly simplified. It might also be a good idea tounlink()
thefilename
after conversion.