Learn R Programming

xplainfi (version 1.0.0)

xplain_opt: xplainfi Package Options

Description

Get or set package-level options for xplainfi.

Usage

xplain_opt(...)

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)

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

OptionDefaultDescription
verboseTRUEShow informational messages (e.g., when using default measure or resampling)
progressFALSEShow progress bars during computation
sequentialFALSEForce sequential execution (disable parallelization)
debugFALSEEnable debug output for development and troubleshooting

Examples

Run this code
# 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