create_yaml_header: Convert list objects into R Markdown YAML headers

Description Usage Arguments Value See Also Examples

View source: R/create_yaml_header.R

Description

This function tweaks the behavior of as.yaml to return a string which can immediately be used as an R Markdown YAML header. It's designed to accept both deeply nested lists and simpler list formats to make reasoning about your header easier.

Usage

1
2
3
4
5
6
7
8
create_yaml_header(
  ...,
  line.sep = c("\n", "\r\n", "\r"),
  indent = 2,
  unicode = TRUE,
  indent.mapping.sequence = FALSE,
  handlers = NULL
)

Arguments

...

A set of objects that will be combined into the YAML header. Objects may be provided as lists (the structure list("outputs" = "html_document") translates to outputs: html_document) or as single-item named vectors (passing "title" = "My Report" to ... will translate to title: "My Report").

line.sep, indent, unicode, indent.mapping.sequence, handlers

Additional arguments to be passed to as.yaml

Value

Returns a string formatted for use as an R Markdown YAML header.

See Also

Other manipulation functions: heddle(), make_template(), provide_parameters(), use_parameters()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
headerContent <- list(
  "title" = "Testing YAML",
  "author" = "Mike Mahoney",
  "output" = list(
    "flexdashboard::flex_dashboard" = list(
      "vertical_layout" = "fill",
      "orientation" = "rows",
      "css" = "bootstrap.css"
    )
  )
)
create_yaml_header(headerContent)
create_yaml_header(
  "title" = "testing",
  "params" = list("data" = "NA"),
  list("author" = "Mike Mahoney")
)

heddlr documentation built on March 24, 2020, 9:07 a.m.