naming {options}R Documentation

Define Naming Conventions

Description

Option naming conventions use sensible defaults so that you can get started quickly with minimal configuration.

Usage

set_envvar_name_fn(fn, env = parent.frame())

set_option_name_fn(fn, env = parent.frame())

Arguments

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

Value

The callback function fn

Functions

Defaults

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.

Setting Alternative Conventions

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.

See Also

naming_formats

Examples

set_envvar_name_fn(envvar_name_generic)

set_envvar_name_fn(function(package, name) {
  toupper(paste("ENV", package, name, sep = "_"))
})


[Package options version 0.2.0 Index]