as_yaml: Serialize a validated configuration list to YAML

View source: R/config.R View source: R/config.R

as_yamlR Documentation

Serialize a validated configuration list to YAML

Description

Validates a configuration list against the package grammar using cfg_validate() and serializes it to a YAML file on disk. This helper is intended for reproducibility and interoperability, allowing a fully specified in-memory configuration to be persisted and reused in subsequent runs or edited manually by users.

Validates config and writes it to path as 'YAML'.

Usage

as_yaml(config, path)

as_yaml(config, path)

Arguments

config

List specification following the package grammar.

path

Output file path (for example "case.yml").

Details

The function performs validation before writing to disk. If validation fails, an error is raised and no file is written. The YAML output is a direct serialization of the validated configuration list and therefore preserves all fields, including nested structures.

Value

The input path, returned invisibly, to allow use in pipelines.

The input path, invisibly.

Examples

tmp <- tempfile(fileext = ".yml")
cfg <- dcf_spec_template()
cfg$entry_yield <- 0.06
as_yaml(cfg, tmp)
stopifnot(file.exists(tmp))

cfg <- dcf_spec_template()
cfg$entry_yield <- 0.06
tmp <- tempfile(fileext = ".yml")
as_yaml(cfg, tmp)
stopifnot(file.exists(tmp))
unlink(tmp)


cre.dcf documentation built on April 10, 2026, 5:08 p.m.