[R-pkg-devel] Suppressing long-running vignette code in CRAN submission

John Harrold john@m@h@rro|d @end|ng |rom gm@||@com
Mon Oct 16 17:29:54 CEST 2023


Hello John,

The way I've done this is I use the the global eval option to control
running the code. When it's set to TRUE it will run the code and save the
results as an RData file. So when I'm creating it locally I have eval=TRUE
in the options:

https://github.com/john-harrold/ubiquity/blob/bb0532915b63f02f701148e5ae097222fef50a2d/vignettes/Simulation.Rmd#L11

Then when I want to use the results I load them from a file:

https://github.com/john-harrold/ubiquity/blob/bb0532915b63f02f701148e5ae097222fef50a2d/vignettes/Simulation.Rmd#L101

Then before I submit to CRAN I set eval=FALSE in the setup at the top of
the vignette.

John

On Mon, Oct 16, 2023 at 7:15 AM John Fox <jfox using mcmaster.ca> wrote:

> Dear list members,
>
> I believe that this issue has been discussed previously, but I'm not
> sure that I have the solution right.
>
> Georges Monette and I have developed a package that we intend to submit
> soon to CRAN which has a vignette including code that takes a long time
> to run. The sources for the package are available at
> <https://github.com/gmonette/cv>.
>
> We figure that we have to suppress running the code the vignette when
> CRAN checks the package or the check time will be excessive.
>
> The vignette is written as a .Rmd file to be compiled by knitr,
> producing an HTML vignette. The top of the .Rmd file looks like this:
>
> ------- snip -------
>
> ---
> title: "Cross-validation of regression models"
> author: "John Fox and Georges Monette"
> date: "`r Sys.Date()`"
> package: cv
> output:
>    rmarkdown::html_vignette:
>    fig_caption: yes
> bibliography: ["cv.bib"]
> csl: apa.csl
> vignette: >
>    %\VignetteIndexEntry{Cross-validation of regression models}
>    %\VignetteEngine{knitr::rmarkdown}
>    %\VignetteEncoding{UTF-8}
> ---
>
> ```{r setup, include = FALSE}
> knitr::opts_chunk$set(
>    collapse = TRUE,
>    message = TRUE,
>    warning = TRUE,
>    fig.align = "center",
>    fig.height = 6,
>    fig.width = 7,
>    fig.path = "fig/",
>    dev = "png",
>    comment = "#>",
>    eval = nzchar(Sys.getenv("REBUILD_CV_VIGNETTES"))
> )
>
> ### other irrelevant setup code not shown ###
>
> ```
>
> ------- snip -------
>
> So (near the bottom), if the environment variable REBUILD_CV_VIGNETTES
> isn't empty, the code blocks in the vignette are evaluated, otherwise
> not. To build the tarball for the package to be submitted to CRAN, we
> will set REBUILD_CV_VIGNETTES to "true". That works as intended.
>
> If we submit the tarball to CRAN, I believe that the package as
> distributed by CRAN will include the HTML vignette from our tarball,
> showing the evaluated code blocks, but when CRAN checks the package,
> these long-running code blocks will not be executed (because
> REBUILD_CV_VIGNETTES will not exist on the CRAN check machines).
>
> My questions:
>
> Is that correct?
>
> If not, how can we ensure that the complete vignette is distributed by
> CRAN without causing an overly long CRAN check time?
>
> In particular, we don't want CRAN to rebuild and distribute the
> vignette, because the resulting HTML file won't show the evaluated code.
>
> Any assistance would be appreciated.
>
> Thank you,
>   John
> --
> John Fox, Professor Emeritus
> McMaster University
> Hamilton, Ontario, Canada
> web: https://www.john-fox.ca/
>
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

	[[alternative HTML version deleted]]




More information about the R-package-devel mailing list