R/utils.R

Defines functions check_require

globalVariables(c(".", "admin", "excluded_files", "linter"))

check_require <- function(pkg) {
  full_pkgname <- pkg
  pkgname <- basename(full_pkgname)

  if (!requireNamespace(pkgname, quietly = TRUE)) {
    usethis::ui_stop(
      "Package {usethis::ui_field(pkgname)} needed for this function to work!
       Solution: For CRAN, run install.packages(\"{pkgname}\", repos = \"https://cloud.r-project.org\"). For GitHub, run remotes::install_github(\"{full_pkgname}\"). Then try again."
    )
  }
}

Try the misc package in your browser

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

misc documentation built on April 8, 2026, 9:10 a.m.