Learn R Programming

R.AlphA.Home (version 2.0.2)

setOption: Set Global Option from Named List Element

Description

This function takes an element from a named list as an argument, and sets a global option based on the list's name.

Where : optionName$element == "value", calling setOption(optionName$element) triggers options(optionName = "value")

Usage

setOption(listElement)

Value

The function does not return anything but sets an option that can be retrieved using `getOption(list_name)`.

Arguments

listElement

An element from a named list, specified as `myList$element`.

Details

The function automatically extracts the list name from the argument. The option is then dynamically set using `options(list_name = element)`.

Examples

Run this code
# Create a temporary list for demonstration
modelOption <- list(model1 = "model_1", model2 = "model_2", model3 = "model_3")

# Set the option
setOption(modelOption$model1)

# Retrieve the option
getOption("modelOption")  # Returns "model_1"

# Clean up
options(modelOption = NULL)

Run the code above in your browser using DataLab