R/getpkgs.R

Defines functions getpkgs

Documented in getpkgs

#' Get Packages
#'
#' Installs (if necessary) and attaches the specified packages.
#' @param want
#'   A character vector of package names.
#' @param ...
#'   Additional arguments to \code{\link{library}}.
#' @export

getpkgs <- function(want, ...) {
  # install (if necessary) and attach wanted packages
  have <- row.names(installed.packages())
  need <- want[!(want %in% have)]
  if (length(need)>0) {
    install.packages(need, repos="http://cran.r-project.org")
  }
  lapply(want, library, character.only=TRUE, quietly=TRUE, ...)
  invisible()
}
JVAdams/jvamisc documentation built on Aug. 11, 2021, 6:43 a.m.