https://github.com/rstudio/config
config package for R
https://github.com/rstudio/config
Last synced: about 17 hours ago
JSON representation
config package for R
- Host: GitHub
- URL: https://github.com/rstudio/config
- Owner: rstudio
- Created: 2016-05-29T01:48:59.000Z (almost 9 years ago)
- Default Branch: main
- Last Pushed: 2025-04-01T12:37:04.000Z (14 days ago)
- Last Synced: 2025-04-14T23:16:46.404Z (about 17 hours ago)
- Language: R
- Homepage: https://rstudio.github.io/config/
- Size: 7.69 MB
- Stars: 261
- Watchers: 10
- Forks: 30
- Open Issues: 18
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
Awesome Lists containing this project
- jimsghstars - rstudio/config - config package for R (R)
README
---
output: github_document
format: gfm
default-image-extension: ""
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
eval = TRUE
)
```.codeblock-label {
color: #000;
display: inline-block;
border-top-left-radius: .5rem;
border-top-right-radius: .5rem;
padding: 0.25rem 0.75rem;
background-color: #cccccc;
margin-bottom: 0;
font-size: 0.875em;
font-family: var(--bs-font-monospace);
}
.codeblock-label + div.sourceCode {
margin-top: 0;
}```{r child="man/fragments/knitr_with_config_hooks.Rmd", include = FALSE}
```# config
[](https://CRAN.R-project.org/package=config)
[](https://www.r-pkg.org/pkg/miniCRAN)
[](https://github.com/rstudio/config/actions)
[](https://app.codecov.io/gh/rstudio/config?branch=main)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:
``` r
install.packages("config")
```## Usage
To use `config`, create a file `config.yml` with default as well as other arbitrary configurations. For example:
```{yaml output.var="config_yaml"}
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, with_config=TRUE, config_yml="config_yaml"}
config <- config::get()
config$trials
config$dataset
```You can also read a single value from the configuration as follows:
```{r, with_config=TRUE, config_yml="config_yaml"}
config::get("trials")
config::get("dataset")
```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 for more examples and instructions for advanced usage, including:
- Inheritance and R expressions
- Using `config` on Posit Connect```{r child="man/fragments/no_attach.Rmd"}
```