Skip to contents

This function checks whether a specified package is installed in the current R environment. Optionally, it can install the package if it is not already installed.

Usage

package_installed(pkg, install_if_missing = FALSE)

Arguments

pkg

A character string specifying the name of the package to check.

install_if_missing

A logical value indicating whether to install the package if it is not installed. Default is FALSE.

Value

A logical value: TRUE if the package is installed (or successfully installed), FALSE otherwise.

Examples

if (FALSE) { # \dontrun{
org::package_installed("data.table")
org::package_installed("ggplot2", install_if_missing = TRUE)
} # }