Skip to contents

This is wrapper around rlang::check_installed; instead of erroring out if the check fails it returns FALSE. However, unlike rlang::is_installed, it emits a message to the user.

Usage

is_installed2(...)

Arguments

...

Arguments passed on to rlang::check_installed

pkg

The package names. Can include version requirements, e.g. "pkg (>= 1.0.0)".

version

Minimum versions for pkg. If supplied, must be the same length as pkg. NA elements stand for any versions.

compare

A character vector of comparison operators to use for version. If supplied, must be the same length as version. If NULL, >= is used as default for all elements. NA elements in compare are also set to >= by default.

reason

Optional string indicating why is pkg needed. Appears in error messages (if non-interactive) and user prompts (if interactive).

action

An optional function taking pkg and ... arguments. It is called by check_installed() when the user chooses to update outdated packages. The function is passed the missing and outdated packages as a character vector of names.

call

The execution environment of a currently running function, e.g. caller_env(). The function will be mentioned in error messages as the source of the error. See the call argument of abort() for more information.

See also

Examples

rlang::with_interactive(is_installed2("idonotexist"), FALSE)
#> The optional package "idonotexist" is missing..
#> This message is displayed once per session.
#> [1] FALSE
rlang::with_interactive(is_installed2("base"), FALSE)
#> [1] TRUE