Skip to contents

This function checks library dependencies

Usage

try_require(package, stop = TRUE, load = TRUE, lib.loc = NULL, ...)

Arguments

package

Character. Name of the library

stop

Boolean. Stop if not installed. If FALSE and library is not available, warning will be shown.

load

Boolean. Load library?

lib.loc

Character vector. Location of R library trees to search through, or NULL. The default value of NULL corresponds to all libraries currently known to .libPaths(). Non-existent library trees are silently ignored.

...

Additional parameters.

Value

No return value, called for side effects.

Examples

# Check if library base is installed. If not, stop and show error
try_require("base", stop = TRUE)
# Check if library xxx is installed. If not, show warning
try_require("xxx", stop = FALSE)
#> Warning: Package 'xxx' recommended. Install for better results.