This function checks if the specified R packages are installed and loads them.
If a package is not installed, it attempts to install it from the specified CRAN repositories.
Usage
load_packages(..., silent = FALSE)
Arguments
- ...
A list of package names to be installed and/or loaded. Names should be provided as unquoted identifiers.
- silent
Logical, default is FALSE. If TRUE, suppresses printing of package loading statuses.
Value
A named logical vector indicating whether each package was successfully loaded.
Details
This function ensures that all specified packages are installed and loaded in the current R session.
Missing packages are automatically installed from CRAN. The function also provides an option
to suppress output messages.
Examples
if (FALSE) { # \dontrun{
# Example 1: Load and install ggplot2 and dplyr
load_packages(ggplot2, dplyr)
# Example 2: Load packages silently
load_packages(ggplot2, dplyr, silent = TRUE)
} # }