R/inst.packs.R

#' Multiple package installation (without loading)
#' 
#' The \code{inst.packs} function takes a single command, a list of package names, and will install them, if not already installed.
#' @param packlist A list of package names as a vector of quoted strings.
#' @keywords inst pack
#' @export
#' @examples 
#' inst.packs(c("ggplot2", "dplyr"))

inst.packs <- function(packlist = c()) 
{
  packages <- c(packlist)
  for (i in 1:length(packages)) {
    if (!is.element(packages[i], installed.packages()[, 1])) {
      message(paste("Package", packages[i], "not found, installing..."))
      install.packages(packages[i], dep = TRUE, verbose = TRUE)
    }
  }
}
AFMSAnalytics/utilityScripts documentation built on May 30, 2019, 10:45 p.m.