I am using RStudio for package development in windows environment. I need to enable pdf vignette compression to avoid 'gs+qpdf' made some significant size reductions:
warning.
I have added --compact-vignettes="gs+qpdf"
as additional options to Project Options : Build Tools > Build Source Package, but there is no change in the size of pdf vignette in the source package built using devtools::build()
.
I have also added to the YAML header in the vignette latex compression options as follows.
header-includes:
- \pdfminorversion=5
- \pdfcompresslevel=9
- \pdfobjcompresslevel=2
Still there is no change.
However I am getting the desired compression while using tools::compactPDF
with gs_cmd = Sys.getenv("R_GSCMD")
and gs_quality = "ebook
arguments.
How to get the desired compression while building packages for avoiding the warning?
The easiest way to create a vignette in RStudio is using File | New File | R Markdown | From Template | Package Vignette (HTML). Write your RMarkdown document.
R package vignettes are user-friendly ways to demo your package’s capabilities. They can also be helpful documentation for your own reference when modifying the package in the future — “what was I thinking there?” The easiest way to create a vignette in RStudio is using File | New File | R Markdown | From Template | Package Vignette (HTML).
It turns out, according to RStudio’s slightly-outdated online documentation this behavior is to be expected because, presumably, developers don’t want to worry about vignettes in the typical code/Install-and-Restart/re-code development cycle [I get that]; to wit: RStudio’s “Build & reload” does not build vignettes to save time.
There are three R package build commands used by the package development tools in the RStudio IDE: It's possible to customize the options passed to each of these commands using Project Options : Build Tools: To obtain a summary of the valid options simply execute the command with the --help option in ain a terminal window.
I've found, for some reason (perhaps related to the quotes?), that RStudio doesn't like the --compact-vignettes="gs+qpdf"
.
Instead, I used --compact-vignettes=both
, which did the trick for me, when using RStudio's "Build" panel.
From the command line, you'd need to type devtools::build(build_args = c('--compact-vignettes=both'))
.
https://support.rstudio.com/hc/en-us/articles/200486518-Customizing-Package-Build-Options has more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With