must.use.package: Do everything possible to load an R package.

View source: R/NCmisc.R

must.use.packageR Documentation

Do everything possible to load an R package.

Description

Like 'require()' except it will attempt to install a package if necessary. Installation of bioconductor packages is deprecated. Useful if you wish to share code with people who may not have the same libraries as you, you can include a call to this function which will simply load the library if present, or else install, then load, if they do not have it.

Usage

must.use.package(
  pcknms,
  ask = FALSE,
  reload = FALSE,
  avail = FALSE,
  quietly = FALSE
)

Arguments

pcknms

list of packages to load/install

ask

whether to get the user's permission to install a required package, or just go ahead and do it

reload

indicates to reload the package even if loaded

avail

see whether pcknms are in the list of available CRAN packages

quietly

passed to library/require, display installation text or not

Value

nothing, simply loads the packages specified if possible

Author(s)

Nicholas Cooper njcooper@gmx.co.uk

Examples

# not run : run if you are ok to install/already have these packages
# must.use.package(c("MASS","nlme","lme4"),ask=FALSE)
# search() # show packages have loaded, then detach them again:
# sapply(paste("package",c("MASS","nlme","lme4"),sep=":"),detach,character.only=TRUE)

NCmisc documentation built on Oct. 17, 2022, 5:09 p.m.