Togaware DATA MINING
Desktop Survival Guide
by Graham Williams
Google

Testing Package Availability

If a function you write depends on the functionality of some package, such as gplots, use the stopifnot function to exit if the package is not available:

myfun <- function()
{
  stopifnot(require(gplots))
  [...]
}

Also, the .packages can be used to list all packages that have been installed on your system:

> .packages(all=TRUE)
 [1] "acepack"              "ada"                  "amap"                
 [4] "arules"               "bitops"               "butler"              
[..]
[73] "tcltk"                "tools"                "utils"               
[76] "mapdata"

And a call to the library function with no arguments will list all packages installed, and a one line description:

> library()
Packages in library '/usr/lib/R/library':

base                    The R Base Package
datasets                The R Datasets Package
graphics                The R Graphics Package

[...]

Packages in library '/usr/local/lib/R/site-library':

acepack                 ace() and avas() for selecting regression
                        transformations
ada                     Performs boosting algorithms for a binary
                        response

[...]

XML                     Tools for parsing and generating XML within R
                        and S-Plus.
xtable                  Export tables to LaTeX or HTML



Copyright © Togaware Pty Ltd
Support further development through the purchase of the PDF version of the book.
The PDF version is a formatted comprehensive draft book (with over 800 pages).
Brought to you by Togaware. This page generated: Sunday, 22 August 2010