How can I extend this code to store installation status messages in addition to names of packages? I want to use verbose = TRUE
to minimize amount of output and not show any message if installation was succesfull.
packages_lst <- c("dplyr", "xlsx", "zoo")
missing <- c()
for (pkg in packages_lst){
install.package(pkg, verbose = TRUE)
if !(pkg %in% installed.packages()){
message(paste("Installation failed for ", pkg)
missing <- c(missing, pkg)}
}
message(paste("Finished. Failed to install packages: ", paste(missing, collapse = ","))
(Yes, I know I could simplify this code and just print difference between packages_lst
and installed.packages()
with no need to create missing
variable, but it is here to store status messages.)
1