R/utils.r

Defines functions try_require

try_require <- function(package, fun) {
  if (requireNamespace(package, quietly = TRUE)) {
    library(package, character.only = TRUE)
    return(invisible())
  }

  stop("Package `", package, "` required for `", fun , "`.\n", # nocov start
    "Please install and try again.", call. = FALSE) # nocov end
}
hrbrmstr/sergeant documentation built on Sept. 18, 2017, 7:41 a.m.