Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling vignette compression for R CMD build in RStudio

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?

like image 225
Crops Avatar asked Jul 20 '15 06:07

Crops


People also ask

How do I create a vignette in RStudio?

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.

What are package vignettes in R?

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).

Why doesn’t RStudio’s “build&reload” build vignettes?

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.

How do I customize the R package build commands?

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.


1 Answers

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.

like image 186
Martin Smith Avatar answered Nov 15 '22 23:11

Martin Smith