When I install the yaml package, an annoying error message pops up in RStudio if it had been previously installed. How can I tell if the package was already installed so I can d
This will load yaml
, installing it first if its not already installed:
if (!require(yaml)) {
install.packages("yaml")
library(yaml)
}
or if you want to parameterize it:
pkg <- "yaml"
if (!require(pkg, character.only = TRUE)) {
install.packages(pkg)
if (!require(pkg, character.only = TRUE)) stop("load failure: ", pkg)
}
UPDATE. Parametrization.