Free Access Week-  Data Engineering + BI
Data engineering and BI courses are free!
Free AI Access Week from June 2-8

NCmisc (version 1.1.6)

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

Description

Like 'require()' except it will attempt to install a package if necessary, and will also deal automatically with bioconductor packages too. 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, bioC = FALSE, ask = FALSE, reload = FALSE,
  avail = FALSE, quietly = FALSE)

Value

nothing, simply loads the packages specified if possible

Arguments

pcknms

list of packages to load/install, shouldn't mix bioconductor/CRAN in one call

bioC

whether the listed packages are from bioconductor

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

when bioC=FALSE, see whether pcknms are in the list of available CRAN packages

quietly

passed to library/require, display installation text or not

Author

Nicholas Cooper njcooper@gmx.co.uk

Examples

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

Run the code above in your browser using DataLab