R/zzz.R

Defines functions has_pkg assert

assert <- function(x, y) {
  if (!is.null(x)) {
    if (!inherits(x, y)) {
      stop(deparse(substitute(x)), " must be of class ",
        paste0(y, collapse = ", "), call. = FALSE)
    }
  }
}

has_pkg <- function(x) {
  if (!requireNamespace(x, quietly = TRUE)) {
    stop("install ", x, call. = FALSE)
  }
}
ropensci/mutant documentation built on Dec. 30, 2021, 11:53 a.m.