require2: Loading Packages (and Installing them if they are missing)

View source: R/install.R

require2R Documentation

Loading Packages (and Installing them if they are missing)

Description

require2 load add-on packages by passing it to require. However, if the package is not available on the system, it will first install it (through install.packages), and only then try to load it again.

Usage

require2(package, ask = FALSE, character.only = FALSE, min_version = 0)

Arguments

package

A character of the name of a package (can also be without quotes).

ask

Should the user be asked to install the require packaged, in case it is missing? (default is FALSE)

character.only

logical (FALSE) - a logical indicating whether package or help can be assumed to be character strings. Passed to require.

min_version

Minimum version of package

Value

returns (invisibly) a logical indicating whether the required package is available.

Examples

## Not run: 
require2("devtools")
require2(geonames)
require2(pkgbuild, min_version = "1.1.0")
data_table_loaded <- require2("data.table")

## End(Not run)

installr documentation built on Nov. 13, 2022, 1:06 a.m.