From bbolker at gmail.com  Sun Apr 15 02:45:06 2012
From: bbolker at gmail.com (Ben Bolker)
Date: Sat, 14 Apr 2012 20:45:06 -0400
Subject: [Rd] R CMD check with non-standard .libPaths
Message-ID: <4F8A1A12.1040004@gmail.com>


  Does anyone have advice on how to instruct R CMD check to use a
non-standard set of libraries?  Here's the situation:

  I'm trying to do some automated checking on package dependencies of a
package I maintain.  In order to do that I've written code that takes
the list of the dependent packages and for each package (1) downloads
the most recent/available .tar.gz file; (2) installs the "Suggests:" and
"Depends:" packages for the package that are not already installed; (3)
runs R CMD check and stores the output.

  I wanted to do this in a way that would not necessarily bloat my base
installation, so I wanted to do step #2 into a new library.  Once I've
figured out what the missing dependencies are (depMiss), I

 install.packages(depMiss,lib=libdir)

Then I run R CMD check as follows.

   ss <- suppressWarnings(system(
   paste("export R_LIBS=./library; R CMD check",
               file.path(tarballdir,tn)),
                 intern=TRUE))

However, this only seems to work partially.  It does prevent the check
from failing with an error that the package doesn't exist: *BUT* when
the examples are actually run, I get results like this (this is from the
'agridat' package, which "Suggests:" the hglm package, which has hence
been installed in the 'libdir' directory).

[168] "168: Loading required package: hglm"

[169] "169: Warning in library(package, lib.loc = lib.loc,
character.only = TRUE, logical.return = TRUE,  :"
[170] "170:   there is no package called ?hglm?"

  Checking installed.packages() shows that hglm is indeed installed in
the appropriate directory.  agridat "Suggests:" hglm.  The
"crowder.germination" example in agridat tries require(hglm) and fails;
it therefore doesn't fit the relevant HGLM model -- when the example
tries to reference this model a few lines later, the example fails.
Admittedly this could be seen as a bug in the example (it shouldn't try
to access a model it knows it can't fit), but I wonder if there's a way
I can get the examples run to see the non-standard package location.

   I could (I guess) modify my .Rprofile temporarily ... ?  But I'm
curious if there's a right way to do this ...

  thanks
    Ben Bolker



[Rd] R CMD check with non-standard .libPaths
Ben Bolker