check_pkg_installed()
: checks whether a package is installed and returns an error orFALSE
if not available. If a package search is provided, the function will check whether a minimum version of a package is required.get_pkg_dependencies()
returns a tibble with all dependencies of a specific package.get_min_version_required()
will return, if any, the minimum version ofpkg
required byreference_pkg
,NULL
if no minimum version required.
Usage
check_pkg_installed(pkg, reference_pkg = "cards", call = parent.frame())
is_pkg_installed(pkg, reference_pkg = "cards", call = parent.frame())
get_pkg_dependencies(reference_pkg = "cards", lib.loc = NULL)
get_min_version_required(pkg, reference_pkg = "cards", lib.loc = NULL)
Arguments
- pkg
(
string
)
name of required package- reference_pkg
(
string
)
name of the package the function will search for a minimum required version from.- call
(
environment
)
frame for error messaging. Default isparent.frame()
.- lib.loc
(
path
)
location ofR
library trees to search through, seeutils::packageDescription()
.
Value
check_pkg_installed()
returns a logical or error, get_min_version_required()
returns NULL
or a string with the minimum version required, get_pkg_dependencies()
returns a tibble.
Examples
check_pkg_installed("dplyr")
is_pkg_installed("dplyr")
#> [1] TRUE
get_pkg_dependencies()
#> # A tibble: 10 × 6
#> reference_pkg reference_pkg_version dependency_type pkg version compare
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 cards 0.1.0 Imports cli 3.6.1 >=
#> 2 cards 0.1.0 Imports dplyr 1.1.2 >=
#> 3 cards 0.1.0 Imports glue 1.6.2 >=
#> 4 cards 0.1.0 Imports rlang 1.1.1 >=
#> 5 cards 0.1.0 Imports tidyr 1.3.0 >=
#> 6 cards 0.1.0 Imports tidysele… 1.2.0 >=
#> 7 cards 0.1.0 Depends R 4.1 >=
#> 8 cards 0.1.0 Suggests spelling 2.2.0 >=
#> 9 cards 0.1.0 Suggests testthat 3.2.0 >=
#> 10 cards 0.1.0 Suggests withr 3.0.0 >=
get_min_version_required("dplyr")
#> Imports
#> "1.1.2"
#> attr(,"compare")
#> [1] ">="