The function checks whether a package is installed and returns an error or FALSE if not available. If a package search is provided, the function will check whether a minimum version of a package is required.

.assert_package(pkg, fn = NULL, pkg_search = "broom.helpers", boolean = FALSE)

.get_min_version_required(pkg, pkg_search = "broom.helpers")

Arguments

pkg

Package required

fn

Calling function from the user perspective. Used to write informative error messages.

pkg_search

the package the function will search for a minimum required version from.

boolean

logical indicating whether to return a TRUE/FALSE, rather than error when package/package version not available. Default is FALSE, which will return an error if pkg is not installed.

Value

logical or error

Examples

.assert_package("broom", boolean = TRUE)
#> [1] TRUE

.get_min_version_required("brms")
#> NULL