Search code examples
rbuildpackage

How to consider custom arguments of a package while building vignette?


I have a package which requires some custom arguments for installation. I can use R CMD INSTALL ---configure-args=... pkg.tar.gz to install the package successfully. I can also use R CMD check --install-args=configure-args=... to check the package after getting the custom arguments. However, R CMD build doesn't have any arguments like --install-args and/or configure-args and R CMD build is used for building vignettes. I want to get the output of my R code chunks included in the vignette to its html output file and include it in the package source. Is there any way possible to build vignette with --configure-args or is there any workaround to produce the desired html vignette and include it in the package source?

Looking forward to your suggestions.


Solution

  • As you say, when R CMD build rebuilds your vignettes, it doesn't include a way to specify --include-args, so the temporary install needs to work with default settings.

    There are two ways to achieve this. You could specify --no-build-vignettes. This would require that you have already put the built vignettes into the inst/doc directory, and R CMD build will just use what's there.

    The other way is to make sure that on your machine the default configuration works. If you need to build on several different machines, this could be achieved by having your build script look at environment variables to find default settings if corresponding configure arguments aren't given. Then on each machine you specify the environment variables for R CMD build to see, e.g.

    DEFAULT_LOCATION="/some/dir" R CMD build yourpackage