[Rd] require is to suggests as what is to imports?

Dirk Eddelbuettel edd at debian.org
Wed Aug 25 15:27:41 CEST 2010


On 25 August 2010 at 08:06, Prof Brian Ripley wrote:
| On Tue, 24 Aug 2010, Dirk Eddelbuettel wrote:
| 
| >
| > On 24 August 2010 at 15:40, Hadley Wickham wrote:
| > | Hi all,
| > |
| > | If a package suggests another package in its description, you can
| > | check it at runtime with requires.  How do you do check if a package
| > | is available without loading it, if you only want to access one
| > | function in the package namespace.
| >
| > I needed this a few days ago for a small package and resorted to this:
| >
| >   .packages <- as.character(installed.packages()[,1])
| >
| >   [...]
| >
| >   hasGputools <- function() {
| >       any( "gputools" == .packages )
| >   }
| >
| > That way I get around Depends, Suggests and other thing that may impact the
| > running of 'R CMD check' and friends.
| 
| But thereby clobber your users with the run-time cost of 
| installed.packages() (which can take several minutes on some Windows 

Yes. As that was for a so-far internal-only package that in all likelihood
will never be built on Windows for limitations of the latter platform.

Regardless, I will switch to Henrik's elegant alternative.

| systems, and just took ca 12secs on my fastest Linux server with 3000 
| packages installed).  If you want to take this route (is a package 
| installed?), see the 'Note' on ?installed.packages for better 
| alternatives.

My version of ?installed.packages has no section "Note". That is on the on
the current, released version of R.

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com



More information about the R-devel mailing list