Last data update: 2014.03.03

R: Set Options with Consistency Checks
check.optionsR Documentation

Set Options with Consistency Checks


Utility function for setting options with some consistency checks. The attributes of the new settings in new are checked for consistency with the model (often default) list in name.opt.


check.options(new, name.opt, reset = FALSE, assign.opt = FALSE,
              envir = .GlobalEnv,
              check.attributes = c("mode", "length"),
              override.check = FALSE)



a named list


character with the name of R object containing the default list.


logical; if TRUE, reset the options from name.opt. If there is more than one R object with name name.opt, remove the first one in the search() path.


logical; if TRUE, assign the ...


the environment used for get and assign.


character containing the attributes which check.options should check.


logical vector of length length(new) (or 1 which entails recycling). For those new[i] where override.check[i] == TRUE, the checks are overridden and the changes made anyway.


A list of components with the same names as the one called name.opt. The values of the components are changed from the new list, as long as these pass the checks (when these are not overridden according to override.check).


Option "names" is exempt from all the checks or warnings, as in the application it can be NULL or a variable-length character vector.


Martin Maechler

See Also

ps.options and pdf.options, which use check.options.


(L1 <- list(a = 1:3, b = pi, ch = "CH"))
check.options(list(a = 0:2), name.opt = "L1")
check.options(NULL, reset = TRUE, name.opt = "L1")


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(grDevices)
> png(filename="/home/ddbj/snapshot/RGM3/R_rel/result/grDevices/check.options.Rd_%03d_medium.png", width=480, height=480)
> ### Name: check.options
> ### Title: Set Options with Consistency Checks
> ### Aliases: check.options
> ### Keywords: utilities programming
> ### ** Examples
> (L1 <- list(a = 1:3, b = pi, ch = "CH"))
[1] 1 2 3

[1] 3.141593

[1] "CH"

> check.options(list(a = 0:2), name.opt = "L1")
[1] 0 1 2

[1] 3.141593

[1] "CH"

> check.options(NULL, reset = TRUE, name.opt = "L1")
[1] 1 2 3

[1] 3.141593

[1] "CH"

null device