# Get current value of an option
xplain_opt("verbose")
# Get all options
xplain_opt()
# Set an option (returns previous value invisibly)
old <- xplain_opt(verbose = FALSE)
xplain_opt("verbose") # Now FALSE
# Restore previous value
xplain_opt(verbose = old$verbose)
# Temporary option change with withr
if (requireNamespace("withr", quietly = TRUE)) {
withr::with_options(
list("xplain.verbose" = FALSE),
{
# Code here runs with verbose = FALSE
xplain_opt("verbose")
}
)
}
Run the code above in your browser using DataLab