From edd at debian.org  Tue Aug 24 22:51:31 2010
From: edd at debian.org (Dirk Eddelbuettel)
Date: Tue, 24 Aug 2010 15:51:31 -0500
Subject: [Rd] require is to suggests as what is to imports?
In-Reply-To: <AANLkTi=EOFdYKP0JUZLCz8r7KRJ1PaYFGQgresAQJ6r1@mail.gmail.com>
References: <AANLkTi=EOFdYKP0JUZLCz8r7KRJ1PaYFGQgresAQJ6r1@mail.gmail.com>
Message-ID: <19572.12499.732450.953347@max.nulle.part>


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.

Dirk

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



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