Skip to content

This function checks if a specified package is installed in the R environment. If the package is not installed, it will be automatically installed. After installation (if necessary), the package is loaded into the session.

Usage

check_and_load_package(package_name)

Arguments

package_name

A string with the name of the package to check and load.

Value

Invisibly returns `TRUE` if the package is successfully loaded or installed and loaded. If the installation or loading fails, an error will be raised.

Examples

check_and_load_package("httr2")
check_and_load_package("xml2")