naming | R Documentation |
Option naming conventions use sensible defaults so that you can get started quickly with minimal configuration.
set_envvar_name_fn(fn, env = parent.frame())
set_option_name_fn(fn, env = parent.frame())
fn |
A callback function which expects two arguments, the package name and option name, and returns a single character value to use as an environment variable name. |
env |
An environment in which to search for options settings |
The callback function fn
set_envvar_name_fn()
: Set a callback function to use to format environment variable names.
set_option_name_fn()
: Set a callback function to use to format option names.
Given a package mypackage
and option myoption
, the default settings
will generate options and environment variables using the convention:
option:
mypackage.myoption
environment variable:
R_MYPACKAGE_MYOPTION
This convention is intended to track closely with how options and environment
variables are handled frequently in the wild. Perhaps in contrast to the
community conventions, an R_
prefix is tacked on to the default environment
variables. This prefix helps to differentiate environment variables when
similarly named tools exist outside of the R ecosystem.
If you choose to use alternative naming conventions, you must set the callback function before defining options. This is best achieved by altering these settings in the file where you define your options.
If you choose to break up your options across multiple files, then it is best to define the collate order for your R scripts to ensure that the options are consistently configured across operating systems.
naming_formats
set_envvar_name_fn(envvar_name_generic)
set_envvar_name_fn(function(package, name) {
toupper(paste("ENV", package, name, sep = "_"))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.