is_pkg_installed | R Documentation |
Returns TRUE
or FALSE
for each pkg
, depending on whether the pkg
is installed on the current system or not, optionally ensuring a min_version
.
is_pkg_installed(pkg, min_version = NULL)
pkg |
Package names. A character vector. |
min_version |
Minimum required version number of each |
In contrast to base::require()
, this function checks if the packages are installed without attaching their namespaces if so.
In contrast to rlang::is_installed()
or xfun::pkg_available()
, this function doesn't load the packages if they're installed.
In contrast to xfun::pkg_available()
, it is fully vectorized, i.e. returns a (named) logical vector of the same length as pkg
.
It is considerably faster than the commonly used
pkg %in% rownames(installed.packages())
check.
A named logical vector of the same length as pkg
.
Other R package functions:
is_pkg_cran()
,
is_pkg_dir()
,
is_pkgdown_dir()
,
ls_pkg()
,
use_pkg()
pal::is_pkg_installed("tidyverse")
# it is vectorized...
pal::is_pkg_installed(pkg = c("dplyr", "tibble", "magrittr"),
min_version = c("1.0", "2.0", "99.9.9000"))
# ...and scalar arguments will be recycled
pal::is_pkg_installed(pkg = "dplyr",
min_version = c("0.5", "1.0", "99.9.9000"))
pal::is_pkg_installed(pkg = c("dplyr", "tibble", "magrittr"),
min_version = "1.0")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.