clone_and_merge: Create a local, altered copy of an options manager

Description Usage Arguments Value Details See Also Examples

View source: R/options.R

Description

Local options management.

Usage

1

Arguments

options

A function as returned by options_manager or clone_and_merge.

...

Options to be merged, in the form of [name]=[value] pairs.

Value

A option manager like options, with possibly different settings.

Details

This function creates a copy of the options manager options, with the same defaults. However, the current settings may be altered by passing extra arguments. Its intended use is to allow for easy merging of local options with global settings in a function call.

Some more examples can be found in the vignette: vignette('settings',package='options').

See Also

options_manager, reset, defaults

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Create global option manager.
opt <- options_manager(foo=1,bar='a')

# create an altered copy
loc_opt <- clone_and_merge(opt, foo=2)

# this has no effect on the 'global' version
opt()
# but the local version is different
loc_opt()

# we alter the global version and reset the local version
opt(foo=3)
reset(loc_opt)
opt()
loc_opt()

# create an options manager with some option values limited
opt <- options_manager(prob=0.5,y='foo',z=1,
  .allowed=list(
     prob = inrange(min=0,max=1)
     , y    = inlist("foo","bar")
   )
 )
# change an option
opt(prob=0.8)
opt("prob")
## Not run: 
# this gives an error
opt(prob=2)

## End(Not run)

settings documentation built on May 30, 2017, 3:51 a.m.