R/install_pran.R

Defines functions install_pran

Documented in install_pran

#' Install package from PRAN
#'
#' @param pkg package name
#' @param repo_path path to local package repo. Defaults to PRAN path.
#'
#' @export
#'
#' @examples
#' \dontrun{
#' install_pran("prognos.theme")
#' }
install_pran <- function(pkg, repo_path = NULL) {
  if (is.null(repo_path)) {
    warning("No repo path given. Trying to install from PRAN.")
    repo_path <- pran_down()
  } else {
    if (!grepl("file:///", repo_path)) {
      warning("Added 'file:///' to repo path.")
      repo_path <- paste0("file:///", utils::shortPathName(normalizePath(repo_path, winslash = "/")))
    }
  }
  utils::install.packages(pkg, repos = repo_path, type = "source")
}
trekonom/devpran documentation built on Nov. 26, 2019, 12:16 a.m.