[R-pkg-devel] Avoid reprocessing Rmd vignette

Spencer Graves spencer.graves at effectivedefense.org
Tue Mar 20 15:27:04 CET 2018


On 2018-03-20 06:17, Johannes Ranke wrote:
> ...
>
>> The idea exposed by Dirk is the same: requireNamespace will find the
>> package on CRAN and will set eval=TRUE. What you want though is to
>> avoid running a chunk on CRAN, even if the package is available. So
>> you need to set eval=FALSE *unconditionally*.
> Or conditional on the package version (as Dirk proposed regarding tests) or on
> an environment variable NOT_CRAN which you can set to true on the machine
> where you do want to run the code (as used by devtools).


       The function "fda::CRAN" allows package developers to run tests 
themselves that should not run on CRAN or with "R CMD check –as-cran".  
Several of my packages have code in "\examples" that include something 
like the following:


if(!fda::CRAN()){
     #Code I do not want run if a certain parameter is in Sys.getenv()
}


       I have not tried this, but I think you could set a parameter, 
e.g., '-no-vignette' via either Sys.setenv('-no-vignette'=1) or "R CMD 
check -no-vignette", then bracket code snippets in the vignette with 
"if(!fda::CRAN('-no-vignette', '-no-vignette')){...}".


       This will NOT turn off compiling the vignette, but it will allow 
you to suppress running code snippets in the vignette that take time.


       Hope this helps.
       Spencer


p.s.  I just tested "Sys.setenv('-no-vignette'=1);  tst2 <- 
CRAN('-no-vignette', '-no-vignette')" and got TRUE, when CRAN() returned 
FALSE.  When I tried print(tst2) I got:


  [1] TRUE
attr(,"Sys.getenv")
Error in formatDL(x, ...) : unused argument (digits = 7)


       I do not understand this error message, but it does not seem to 
be a problem I have to fix right now, so I won't.

> Johannes
>
> ______________________________________________
> R-package-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel



More information about the R-package-devel mailing list