xplain_opt: xplainfi Package Options

View source: R/utils-opt.R

xplain_optR Documentation

xplainfi Package Options

Description

Get or set package-level options for xplainfi.

Usage

xplain_opt(...)

Arguments

...

Option names to retrieve (as character strings) or options to set (as named arguments).

  • To get an option: xplain_opt("verbose") returns the current value

  • To set an option: xplain_opt(verbose = FALSE) sets the value

  • To get all options: xplain_opt() returns a named list of all options

Details

Options can be set in three ways (in order of precedence):

  1. Using xplain_opt(option_name = value) (recommended)

  2. Using options("xplain.option_name" = value)

  3. Using environment variables XPLAIN_OPTION_NAME=value

Available Options

Option Default Description
verbose TRUE Show informational messages (e.g., when using default measure or resampling)
progress FALSE Show progress bars during computation
sequential FALSE Force sequential execution (disable parallelization)
debug FALSE Enable debug output for development and troubleshooting

Value

  • When getting a single option: the option value (logical)

  • When getting multiple options: a named list of option values

  • When setting options: the previous values (invisibly)

Examples

# 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")
    }
  )
}


xplainfi documentation built on Feb. 27, 2026, 1:08 a.m.