Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R: Skip a vignette being run on CRAN R CMD check

I have a number of vignettes in an R package that are slow to run. As I understand it, a CRAN R CMD check will not rebuild the vignette but will run its corresponding code.

Since the vignettes are slow to run, I don't think the adhere to the CRAN policy. But the vignettes are useful examples that have figures. So I was wondering if it's possible to skip running vignette code only for a CRAN R CMD check, a bit like you can skip a unit test using testthat::skip_on_cran()?

like image 759
Jack Avatar asked Nov 07 '22 19:11

Jack


1 Answers

I just found there is an environment variable used by devtools called NOT_CRAN, and we should be able to use the same ideas to check if things are being run as CRAN. I believe wrapping code in the following if statement will mean it is only run if you are not using the --as-cran statement.

if (identical(Sys.getenv("NOT_CRAN", unset = "true"), "true")) {
    ###CODE HERE###
}

I think even if this has been set by devtools it should still work.

Sources: Testing -- R Packages by Hadley Wickham; testthat package source; devtools package source.

like image 115
Jack Avatar answered Nov 15 '22 06:11

Jack