Description Usage Arguments Value Details Checking options See Also Examples
Set up a set of options with default values and retrieve a manager for it.
1 | options_manager(..., .list, .allowed)
|
... |
Comma separated |
.list |
optional List of |
.allowed |
list of named functions that check an option (see 'checking options') |
A function
that can be used as a custom options manager. It takes as arguments
a comma separated list of option names (character
) to retrieve options or
[name]=[value]
pairs to set options.
The function options_manager
creates an option management function. The returned
function can be uset to set, get, or reset options. The only restriction of the package is
that the following words cannot be used as names for options:
.__reset
.__defaults
For more details and extensive examples see the vignette by copy-pasting this command:
vignette("settings", package = "settings")
Option values can be checked automatically by supplying the options manager
with a named list of functions (.allowed
) that take an option value
and throw an error if it is out-of-range. The functions inlist
and inrange
are convenience functions that create such checking
functions for you.
Reset to default values: reset
.
Retrieve default values: defaults
Create a local, possibly altered copy: clone_and_merge
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # create an options register
my_options <- options_manager(foo=1,bar=2,baz='bob')
### Retrieving options
my_options() # retrieve the full options list.
my_options('baz')
my_options('foo')
# When multiple options are retrieved, the result is a list
my_options('foo','baz')
### Setting global options
my_options(foo=3,baz='pete')
my_options()
### Reset options to default.
reset(my_options)
my_options()
### Limit the possible values for an option.
my_options <- options_manager( fu="bar",.allowed = list(fu=inlist("foo","bar")) )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.