Skip to contents
  • check_pkg_installed(): checks whether a package is installed and returns an error if not available, or interactively asks user to install missing dependency. If a package search is provided, the function will check whether a minimum version of a package is required and installed.

  • is_pkg_installed(): checks whether a package is installed and returns TRUE or FALSE depending on availability. If a package search is provided, the function will check whether a minimum version of a package is required and installed.

  • get_pkg_dependencies() returns a tibble with all dependencies of a specific package.

  • get_min_version_required() will return, if any, the minimum version of pkg required by reference_pkg.

Usage

check_pkg_installed(pkg, reference_pkg = "cards", call = get_cli_abort_call())

is_pkg_installed(pkg, reference_pkg = "cards", call = get_cli_abort_call())

get_pkg_dependencies(
  reference_pkg = "cards",
  lib.loc = NULL,
  call = get_cli_abort_call()
)

get_min_version_required(
  pkg,
  reference_pkg = "cards",
  lib.loc = NULL,
  call = get_cli_abort_call()
)

Arguments

pkg

(character)
vector of package names to check.

reference_pkg

(string)
name of the package the function will search for a minimum required version from.

call

(environment)
frame for error messaging. Default is get_cli_abort_call().

lib.loc

(path)
location of R library trees to search through, see utils::packageDescription().

Value

is_pkg_installed() and check_pkg_installed() returns a logical or error, get_min_version_required() returns a data frame 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.2.2.9008            Imports         cli       3.6.1   >=     
#>  2 cards         0.2.2.9008            Imports         dplyr     1.1.2   >=     
#>  3 cards         0.2.2.9008            Imports         glue      1.6.2   >=     
#>  4 cards         0.2.2.9008            Imports         rlang     1.1.1   >=     
#>  5 cards         0.2.2.9008            Imports         tidyr     1.3.0   >=     
#>  6 cards         0.2.2.9008            Imports         tidysele… 1.2.0   >=     
#>  7 cards         0.2.2.9008            Depends         R         4.1     >=     
#>  8 cards         0.2.2.9008            Suggests        spelling  2.2.0   >=     
#>  9 cards         0.2.2.9008            Suggests        testthat  3.2.0   >=     
#> 10 cards         0.2.2.9008            Suggests        withr     3.0.0   >=     

get_min_version_required("dplyr")
#> # A tibble: 1 × 6
#>   reference_pkg reference_pkg_version dependency_type pkg   version compare
#>   <chr>         <chr>                 <chr>           <chr> <chr>   <chr>  
#> 1 cards         0.2.2.9008            Imports         dplyr 1.1.2   >=