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()
)
TRUE
if all packages in pkg
are available, FALSE
if at least
one of the packages is missing.
needed package
feature description for error message.
logical Should the function throw an error (default) or a warning?
import the listed function to the caller's environment
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()
if (FALSE) # 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()
Run the code above in your browser using DataLab