Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check via requireNamespace if optional packages are loaded #23

Open
dirkschumacher opened this issue Jun 2, 2020 · 3 comments
Open
Labels
good first issue Good for newcomers

Comments

@dirkschumacher
Copy link
Member

Before using them. Otherwise trigger an error. For brms and MASS.

@dirkschumacher dirkschumacher added the good first issue Good for newcomers label Jun 2, 2020
@TimTaylor
Copy link
Member

Something like the following:

glustop <- function(..., .sep = "", .envir = parent.frame()) {
  stop(glue::glue(..., .sep = .sep, .envir = .envir), call. = FALSE)
}

check_suggests <- function(package) {
  if (!requireNamespace(package, quietly = TRUE)) {
    glustop("Suggested package '{package}' not present.")
  }
}

check_suggests("MASS")
check_suggests("treesarecool")
#> Error: Suggested package 'treesarecool' not present.

Created on 2020-08-04 by the reprex package (v0.3.0)

@dirkschumacher
Copy link
Member Author

Yeah. Although maybe good to drop the glue dependency :)

@TimTaylor
Copy link
Member

will be closed by trending ( usage removed :) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants