-
Notifications
You must be signed in to change notification settings - Fork 29
/
README.Rmd
102 lines (74 loc) · 2.73 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
---
output: github_document
format: gfm
default-image-extension: ""
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
eval = TRUE
)
```
<style>
.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;
}
</style>
```{r child="man/fragments/knitr_with_config_hooks.Rmd", include = FALSE}
```
# config <img src='man/figures/logo.svg' align="right" height="139" />
<!-- badges: start -->
[![CRAN status](https://www.r-pkg.org/badges/version/config)](https://CRAN.R-project.org/package=config)
[![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/miniCRAN)](https://www.r-pkg.org/pkg/miniCRAN)
[![R-CMD-check](https://github.com/rstudio/config/workflows/R-CMD-check/badge.svg)](https://github.com/rstudio/config/actions)
[![Codecov test coverage](https://codecov.io/gh/rstudio/config/branch/main/graph/badge.svg)](https://app.codecov.io/gh/rstudio/config?branch=main)
<!-- badges: end -->
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 <https://rstudio.github.io/config/> 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"}
```