目录

config

CRAN
status CRAN RStudio mirror
downloads R-CMD-check Codecov test
coverage

The config package makes it easy to manage environment specific configuration values. For example, you might want to use distinct values for development, testing, and production environments.

Installation

You can install the config package from CRAN by using:

install.packages("config")

Usage

To use config, create a file config.yml with default as well as other arbitrary configurations. For example:

config.yml

default:
  trials: 5
  dataset: "data-sampled.csv"
  
production:
  trials: 30
  dataset: "data.csv"

To read configuration values you call the config::get function, which returns a list containing all of the values for the currently active configuration:

R

config <- config::get()
config$trials
#> [1] 5
config$dataset
#> [1] "data-sampled.csv"

You can also read a single value from the configuration as follows:

R

config::get("trials")
#> [1] 5
config::get("dataset")
#> [1] "data-sampled.csv"

The config::get() function takes an optional config argument which determines which configuration to read values from (the “default” configuration is used if none is specified).

Vignettes

See the package vignettes at https://rstudio.github.io/config/ for more examples and instructions for advanced usage, including:

  • Inheritance and R expressions
  • Using config on Posit Connect

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.

关于

配置管理工具,用于管理R语言项目的配置文件

8.0 MB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802032778号