package: A very silent and multipackage require() function

Description Usage Arguments Value Author(s) See Also Examples

View source: R/package.R

Description

This function loads one or several R packages as silently as possible and it returns TRUE only if all packages are loaded successfully. If at least one loading fails, a short message is printed.

Usage

1
    package(..., warn = TRUE)

Arguments

...

the name of one or several R packages to load (character strings).

warn

If TRUE, issue a warning if one or several packages are not loaded.

Value

TRUE if all packages are loaded correctly, FALSE otherwise. This function is designed to concisely and quitely indicate package requirements in GUI menu or other GUI actions.

Author(s)

Philippe Grosjean <[email protected]>

See Also

require, pkgManLoad

Examples

1
2
3
4
## This should work...
if (all(package("tools", "methods"))) cat("Fine!\n")
## ... but this not
if (!all(package("tools", "badname", warn = FALSE))) cat("Not fine!\n")

svMisc documentation built on May 29, 2017, 12:18 p.m.