R/utils.R

Defines functions .need_pkg

# Internal (not exported): stops with an informative message when a package
# listed in Suggests (needed only by some functions) is not installed.
.need_pkg <- function(pkgs, fun)
{
  miss <- pkgs[!vapply(pkgs, requireNamespace, logical(1), quietly = TRUE)]
  if (length(miss) > 0) {
    stop(sprintf("Function %s requires the package(s) %s. Please install with install.packages(c(%s)).",
                 fun, paste(miss, collapse = ", "),
                 paste0('"', miss, '"', collapse = ", ")), call. = FALSE)
  }
  invisible(TRUE)
}

Try the Compind package in your browser

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

Compind documentation built on Nov. 19, 2026, 5:11 p.m.