Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

check_packages_installed

Check that packages are installed, without loading them


Description

Calls find.package() to check if the all packages are installed.

Usage

check_packages_installed(
  pkgs,
  warn = TRUE,
  msg = "The following packages are required but not installed: %s"
)

Arguments

pkgs

(character())
Packages to check.

warn

(logical(1))
If TRUE, signals a warning of class "packageNotFoundWarning" about the missing packages.

msg

(character(1))
Format of the warning message. Use "%s" as placeholder for the list of packages.

Value

(logical()) named with package names. TRUE if the respective package is installed, FALSE otherwise.

Examples

check_packages_installed(c("mlr3misc", "foobar"), warn = FALSE)

# catch warning
tryCatch(check_packages_installed(c("mlr3misc", "foobaaar")),
  packageNotFoundWarning = function(w) as.character(w))

mlr3misc

Helper Functions for 'mlr3'

v0.10.0
LGPL-3
Authors
Michel Lang [cre, aut] (<https://orcid.org/0000-0001-9754-0393>), Patrick Schratz [aut] (<https://orcid.org/0000-0003-0748-6624>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.