get_option | R Documentation |
Retrieves the value of an zephyr_option
.
The value is looked up in the following order:
User defined option: {pkgname}.{name}
System variable: R_{PKGNAME}_{NAME}
Value of default
argument (if not NULL
)
Default value defined with create_option()
And returns the first set value.
get_option(name, .envir = sys.function(which = -1), default = NULL)
name |
|
.envir |
Environment in which the option is defined. Default is suitable for use inside your package. |
default |
default value to return if the option is not set.
If |
Environment variables are always defined as character strings. In order to return consistent values the following conversions are applied:
If they contain a ";" they are split into a vector using ";" as the delimiter.
If the class of the default value is not character, the value is converted
to the same class using the naive as.{class}
function. E.g. conversions to
numeric are done with as.numeric()
.
These conversions are simple in nature and will not cover advanced cases, but we should try to keep our options this simple.
Value of the option
# Retrieve the verbosity level option set by default in zephyr:
get_option(name = "verbosity_level", .envir = "zephyr")
# Try to retrieve an unset option, which will return the default value:
get_option(
name = "my_unset_option",
.envir = "mypkg",
default = "my_default_value"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.