vignettes/util_load_pkg.Rmd
util_load_pkg.Rmd
The util_load_pkg
function checks if character vector of packages are installed, installs them if they are not currently installed, and loads them.
Typically, packages are installed and loaded using the following code. Installing and loading libraries this way can be tedious especially when the list of packages to install is long. The package are also re-installed even if they are already installed in the system. This takes time.
packages <- c(
"testthat",
"devtools",
"rmarkdown"
)
install.packages(packages)
library("testthat")
library("devtools")
library("rmarkdown")
The above task is executed with a single call below. The function does more. If the packages are already installed, the installation process is skipped. This is a great time saver. All the packages in vector are loaded in the namespace.
library(jeksterslabRutils)
packages <- c(
"testthat",
"devtools",
"rmarkdown"
)
github <- "jalvesaq/colorout"
util_load_pkg(
pkg = packages,
github = github
)