mkoptions is a function that returns a function that behaves like options, with an attached internal/local list of key-value pairs.

mkoptions(...)

.options(..., .DATA)

Arguments

...

list of keys or key-value pairs. For mkoptions these define inital/default key-value pairs.

.DATA

a list or an environment with an element .options.

Functions

  • .options: is a low-level function that mimics the behaviour of the base function options, given a set of key-value pairs. It is the workhorse function used in mkoptions and package-specific option sets (see setupPackageOptions)

See also

Examples

f <- mkoptions(a=3, b=list(1,2,3)) str(f())
#> List of 2 #> $ a: num 3 #> $ b:List of 3 #> ..$ : num 1 #> ..$ : num 2 #> ..$ : num 3
f('a')
#> $a #> [1] 3 #>
f('b')
#> $b #> $b[[1]] #> [1] 1 #> #> $b[[2]] #> [1] 2 #> #> $b[[3]] #> [1] 3 #> #>
str(old <- f(a = 10))
#> List of 1 #> $ a: num 3
str(f())
#> List of 2 #> $ a: num 10 #> $ b:List of 3 #> ..$ : num 1 #> ..$ : num 2 #> ..$ : num 3
f(old) str(f())
#> List of 2 #> $ a: num 3 #> $ b:List of 3 #> ..$ : num 1 #> ..$ : num 2 #> ..$ : num 3