Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

requirePackages

Require some packages.


Description

Packages are loaded either via requireNamespace or require.

If some packages could not be loaded and stop is TRUE the following exception is thrown: “For <why> please install the following packages: <missing packages>”. If why is NULL the message is: “Please install the following packages: <missing packages>”.

Usage

requirePackages(packs, min.versions = NULL, why = "", stop = TRUE,
  suppress.warnings = FALSE, default.method = "attach")

Arguments

packs

[character]
Names of packages. If a package name is prefixed with “!”, it will be attached using require. If a package name is prefixed with “_”, its namespace will be loaded using requireNamespace. If there is no prefix, argument default.method determines how to deal with package loading.

min.versions

[character]
A char vector specifying required minimal version numbers for a subset of packages in packs. Must be named and all names must be in packs. The only exception is when packs is only a single string, then you are allowed to pass an unnamed version string here. Default is NULL, meaning no special version requirements

why

[character(1)]
Short string explaining why packages are required. Default is an empty string.

stop

[logical(1)]
Should an exception be thrown for missing packages? Default is TRUE.

suppress.warnings

[logical(1)]
Should warnings be supressed while requiring? Default is FALSE.

default.method

[character(1)]
If the packages are not explicitly prefixed with “!” or “_”, this arguments determines the default. Possible values are “attach” and “load”. Note that the default is “attach”, but this might/will change in a future version, so please make sure to always explicitly set this.

Value

[logical]. Named logical vector describing which packages could be loaded (with required version). Same length as packs.

Examples

requirePackages(c("BBmisc", "base"), why = "BBmisc example")

BBmisc

Miscellaneous Helper Functions for B. Bischl

v1.11
BSD_2_clause + file LICENSE
Authors
Bernd Bischl [aut, cre], Michel Lang [aut], Jakob Bossek [aut], Daniel Horn [aut], Jakob Richter [aut], Dirk Surmann [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.