R/install.on.demand.R

Defines functions install.on.demand

install.on.demand <- function(pkg, quiet = FALSE, ...) {
  # internal function that checks whether package pkg is
  # in the library. If not found, it asks the user permission
  # to install from CRAN.
  if (requireNamespace(pkg, quietly = TRUE)) {
    return()
  }
  if (interactive()) {
    answer <- askYesNo(paste("Package", pkg, "needed. Install from CRAN?"))
    if (answer) install.packages(pkg, repos = "https://cloud.r-project.org/", quiet = quiet)
  }
}

Try the mice package in your browser

Any scripts or data that you put into this service are public.

mice documentation built on June 7, 2023, 5:38 p.m.