load_yaml_list: Load all YAML fragments from all character vectors in a list

Description Usage Arguments Details Value Examples

View source: R/load_yaml_list.R

Description

These function extracts all YAML fragments from character vectors in a list, returning a list of character vectors containing the extracted fragments.

Usage

1
2
3
4
5
6
7
8
9
load_yaml_list(
  x,
  recursive = TRUE,
  select = ".*",
  delimiterRegEx = "^---$",
  ignoreOddDelimiters = FALSE,
  encoding = "UTF-8",
  silent = TRUE
)

Arguments

x

The list containing the character vectors.

recursive

Whether to first unlist the list (TRUE) or not (FALSE).

select

A vector of regular expressions specifying object names to retain. The default (.*) matches everything, so by default, all objects are retained.

delimiterRegEx

The regular expression used to locate YAML fragments.

ignoreOddDelimiters

Whether to throw an error (FALSE) or delete the last delimiter (TRUE) if an odd number of delimiters is encountered.

encoding

The encoding to use when calling readLines(). Set to NULL to let readLines() guess.

silent

Whether to be silent (TRUE) or informative (FALSE).

Details

This function calls yaml::yaml.load() on all character vectors in a list. It then returns a list where each element is a list with the parsed fragments in a file.

Value

A list of lists of objects.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
yamlList <- list(c(
"---",
"-",
"  id: firstFragment",
"---"), c(
"---",
"-",
"  id: secondFragment",
"  parentId: firstFragment",
"---"));
yum::load_yaml_list(yamlList);

Example output

[[1]]
NULL

[[2]]
NULL

attr(,"class")
[1] "yumFromList" "list"       

yum documentation built on July 17, 2021, 1:07 a.m.