Skip to contents

Export the attributes in a parsed source(s) object to YAML

Usage

export_attributes_from_parsedSources(
  x,
  file = "ROCK_attributes.rock",
  path = NULL,
  preventOverwriting = rock::opts$get("preventOverwriting")
)

Arguments

x

A rock_parsedSource or rock_parsedSources object.

file

The filename to write to; pass NULL to only return the YAML as a character vector

path

If not NULL, this will be combined with the file argument

Value

The YAML as a character vector

Examples

### Get path to example source
examplePath <-
  system.file("extdata", package="rock");

### Get a path to one example file
exampleFile <-
  file.path(examplePath, "example-2.rock");

### Parse single example source
parsedExample <- rock::parse_source(exampleFile);

### Show attributes stord in YAML
### in the source
cat(
  rock::export_attributes_from_parsedSources(
    parsedExample,
    file = NULL
  )
);
#> ---
#> ROCK_attributes:
#> - caseId: 1
#>   region: urban
#>   age: 60s
#> - caseId: 2
#>   region: rural
#>   age: 20s
#> ---