-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
65 lines (46 loc) · 1.85 KB
/
README.Rmd
File metadata and controls
65 lines (46 loc) · 1.85 KB
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
---
output: github_document
---
<!-- 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%"
)
```
# S7schema <a href="https://NovoNordisk-OpenSource.github.io/S7schema"><img src="man/figures/logo.png" align="right" height="120" alt="S7schema website" /></a>
<!-- badges: start -->
[](https://github.com/NovoNordisk-OpenSource/S7schema/actions/workflows/check_and_co.yaml)
<!-- badges: end -->
S7schema provides a generic way of working with yaml config files. The main functionality is captured
in the `S7schema()` class that:
1. Uses [S7](https://rconsortium.github.io/S7/) for easy downstream use in other packages (e.g. new child classes and methods).
2. Uses ['ajv'](https://ajv.js.org) for validation of the config file given [JSON schema](https://json-schema.org).
3. Inherits from `list` ensuring a seamless integration into existing code using the configuration entries.
## Installation
```{r, eval=FALSE}
# Install the development version from GitHub:
pak::pak("NovoNordisk-OpenSource/S7schema")
```
## Usage
```{r}
library(S7schema)
```
A new instance of an `S7schema` class can be initiated with:
```{r, eval=FALSE}
config <- S7schema("path/to/my/config.yml", "path/to/my/schema.json")
```
Since config is a list it can be updated (here adding an "a" element):
```{r, eval=FALSE}
config$a <- 2
```
And it can be validated again:
```{r, eval=FALSE}
validate(config)
```
Which will now throw an error if `a = 2` is an illegal entry according to the schema in `"path/to/my/schema.json"`.
## Learn more
- `vignette("S7schema")` — Getting started
- `vignette("use-in-package")` — Use in a package