View source: R/util_ensure_suggested.R
util_ensure_suggested | R Documentation |
This function stops, if a package is not installed but needed for using an
optional feature of dataquieR
.
util_ensure_suggested(
pkg,
goal = ifelse(is.null(rlang::caller_call()), "work", paste("call",
sQuote(rlang::call_name(rlang::caller_call())))),
err = TRUE,
and_import = c()
)
pkg |
needed package |
goal |
feature description for error message. |
err |
logical Should the function throw an error (default) or a warning? |
and_import |
import the listed function to the caller's environment |
TRUE
if all packages in pkg
are available, FALSE
if at least
one of the packages is missing.
Other robustness_functions:
util_as_valid_missing_codes()
,
util_check_one_unique_value()
,
util_correct_variable_use()
,
util_empty()
,
util_ensure_character()
,
util_ensure_in()
,
util_expect_scalar()
,
util_fix_rstudio_bugs()
,
util_is_integer()
,
util_is_numeric_in()
,
util_is_valid_missing_codes()
,
util_match_arg()
,
util_observations_in_subgroups()
,
util_only_NAs()
,
util_stop_if_not()
,
util_warn_unordered()
## Not run: # internal use, only
f <- function() {
util_ensure_suggested <- get("util_ensure_suggested",
asNamespace("dataquieR"))
util_ensure_suggested("ggplot2", "Test",
and_import = "(ggplot|geom_.*|aes)")
print(ggplot(cars, aes(x = speed)) + geom_histogram())
}
f()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.