isPackageInstalled <- function(package, ...) {
  path <- system.file(package=package);
  (path != "");
}

taken from R.utils (which also has a isPackageLoaded()).

/Henrik

On Tue, Aug 24, 2010 at 1:51 PM, Dirk Eddelbuettel <e...@debian.org> 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.
>
> Dirk
>
> --
> Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to