Learn R Programming

config (version 0.3.2)

get: Read configuration values. Always use as config::get().

Description

Read from the currently active configuration, retrieving either a single named value or all values as a list.

Usage

get(
  value = NULL,
  config = Sys.getenv("R_CONFIG_ACTIVE", "default"),
  file = Sys.getenv("R_CONFIG_FILE", "config.yml"),
  use_parent = TRUE
)

Value

The requested configuration value (or all values as a list of NULL is passed for value).

A list, or vector, corresponding to the contents of the config file.

Arguments

value

Name of value (NULL to read all values)

config

Name of configuration to read from. Defaults to the value of the R_CONFIG_ACTIVE environment variable ("default" if the variable does not exist).

file

Configuration file to read from (defaults to "config.yml"). If the file isn't found at the location specified then parent directories are searched for a file of the same name.

use_parent

TRUE to scan parent directories for configuration files if the specified config file isn't found.

Warning - Do not attach the package using library(config)

We strongly recommend you use config::get() rather than attaching the package using library(config).

In fact, we strongly recommend you never use library(config).

The underlying reason is that the get() and merge() functions in {config} will mask these functions with the same names in base R.

Details

For additional details see https://rstudio.github.io/config/.

See Also

is_active(), merge()

Examples

Run this code

yaml <- "
default:
  trials: 5
  dataset: 'data-sampled.csv'

production:
  trials: 30
  dataset: 'data.csv'
"

get <- base::get



with_config(yaml, config::get())
with_config(yaml, config::get("trials"))

Run the code above in your browser using DataLab