[Rd] Call function only when running via R CMD check?
hb at biostat.ucsf.edu
Thu Nov 3 03:40:26 CET 2011
I'd like to be able to change some default settings only in the case
when checking a package with 'R CMD check'. More precisely, I'd like
to execute a piece of R code before the Rd examples and/or test
scripts are evaluated by 'R CMD check'. Is there a mechanism in 'R
CMD check' that makes this possible? If not, is there a way to detect
that you are running via 'R CMD check', e.g. an R or an environment
variable being set?
The background for this is that some of my packages' examples are
using memoization to cache computational expensive results (via the
'R.cache' package). These are cached to files which are by default
stored under ~/.Rcache/. It turns out that these files live beyond
the check cycle of the CRAN check servers, meaning that the next time
the package is checked memoized results will be picked up. If I could
detect that we're running via 'R CMD check', then I could change the
default cache directory to a temporary directory (e.g. tempdir()) that
will be clean out automatically.
This is not a critical problem, because for now I could explicitly
turn off the memoization in the code of my examples/regression tests,
but the above would be a more generic solution.
More information about the R-devel