option_spec | R Documentation |
An option specification outlines the various behaviors of an option. It's default value, related global R option, and related environment variable name, as well as a description. This information defines the operating behavior of the option.
option_spec(
name,
default = bquote(),
desc = NULL,
option_name = get_option_name_fn(envir),
envvar_name = get_envvar_name_fn(envir),
option_fn = function(value, ...) value,
envvar_fn = envvar_eval_or_raw(),
quoted = FALSE,
eager = FALSE,
envir = parent.frame()
)
name |
A string representing the internal name for the option. This is
the short form |
default |
Either a quoted expression (if parameter |
desc |
A written description of the option's effects |
option_name , envvar_name |
A character value or function. If a character
value is provided it is used as the corresponding global option name or
environment variable name. If a function is provided it is provided with
the package name and internal option name to derive the global option name.
For example, provided with package |
option_fn |
A function to use for processing an option value before being returned from the opt accessor functions. For further details see section "Processing Functions". |
envvar_fn |
A function to use for parsing environment variable values.
Defaults to |
quoted |
A logical value indicating whether the |
eager |
A logical value indicating whether the |
envir |
An environment in which to search for an options envir object. It is rarely necessary to use anything but the default. |
An option_spec
object, which is a simple S3 class wrapping a list
containing these arguments.
Parameters option_fn
and envvar_fn
allow for customizing the way values
are interpreted and processed before being returned by opt
functions.
envvar_fn
When a value is retrieved from an environment variable, the string value
contained in the environment variable is first processed by envvar_fn
.
An envvar_fn
accepts only a single positional argument, and should have a
signature such as:
function(value)
option_fn
Regardless of how a value is produced - either retrieved from an environment
variable, option, a stored default value or from a default provided to an
opt
accessor function - it is then further processed by option_fn
.
The first argument provided to option_fn
will always be the retrieved
value. The remaining parameters in the signature should be considered
experimental. In addition to the value, the arguments provided to opt()
,
as well as an additional source
parameter from opt_source()
may be
used.
Stable
function(value, ...)
Experimental
function(value, x, default, env, ..., source)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.