With no arguments, reactor()
returns an environment that stores the
options, which can also be used to get or set options. For example, with
opts = reactor()
, opts$name
returns an option value, and opts$name = value
sets an option to a value.
With named arguments, reactor()
sets options and returns a list of their
old values (e.g., reactor(echo = FALSE, fig.width = 8)
). The returned
list can be passed to reactor()
later to restore the options.
With unnamed arguments, reactor()
returns option values after received
option names as input. If one name is received, its value is returned
(e.g., reactor('echo')
). If multiple names are received, a named list of
values is returned (e.g., reactor(c('echo', 'fig.width'))
). A special
case is that if only one unnamed argument is received and it takes a list
of named values, the list will be used to set options, e.g.,
reactor(list(echo = FALSE, fig.width = 8))
, which is equivalent to
reactor(echo = FALSE, fig.width = 8)
.