Checks if a package is installed and informs the user if not
Source:R/dependencies.R
is_installed2.Rd
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.
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 aspkg
.NA
elements stand for any versions.compare
A character vector of comparison operators to use for
version
. If supplied, must be the same length asversion
. IfNULL
,>=
is used as default for all elements.NA
elements incompare
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 bycheck_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 thecall
argument ofabort()
for more information.
See also
Other dependencies helper:
pkg_installed
,
pkg_installed_but_not_via_loadall
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