Skip to contents

Removes options from the current R session by name or regular expression pattern.

Usage

remove_options(pattern = NULL, regex = FALSE, case_sensitive = FALSE)

Arguments

pattern

Character vector of option names to remove, or a pattern string if regex = TRUE.

regex

Logical. If TRUE, treat pattern as a regular expression to match option names. Default is FALSE.

case_sensitive

Logical. If TRUE, matching is case-sensitive. Default is FALSE.

Value

Invisibly returns NULL. Removes specified options if found.

Author

Ahmed El-Gabbas

Examples

 # removes option named "my_option"
 options(my_option = 42)
 ecokit::extract_options("my_option")
#> $my_option
#> [1] 42
#> 
 ecokit::remove_options("my_option")
 ecokit::extract_options("my_option")
#> No options found with the specified pattern

 options(plot1 = 42, plot2 = "yes", plot_extra = TRUE)
 ecokit::remove_options("plot_", regex = FALSE)
 ecokit::extract_options("plot")
#> $plot1
#> [1] 42
#> 
#> $plot2
#> [1] "yes"
#> 
#> $plot_extra
#> [1] TRUE
#> 
 ecokit::remove_options("plot_", regex = TRUE)
 ecokit::extract_options("plot")
#> $plot1
#> [1] 42
#> 
#> $plot2
#> [1] "yes"
#>