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.

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

if (FALSE) { require2("devtools") require2(geonames) require2(pkgbuild, min_version = "1.1.0") data_table_loaded <- require2("data.table") }