provide_parameters: Easily provide parameters to R Markdown render calls

Description Usage Arguments See Also Examples

View source: R/provide_parameters.R

Description

R Markdown documents allow you to pass almost any object – including large data frames and functions – to the document as parameters, letting you only define them once to use them in both your document generator and the generated document. This function makes it slightly easier to do so, by automatically creating a named list from provided objects rather than requiring a named list. This function is a stripped-down variant of lst.

Usage

1

Arguments

...

Objects to be included as parameters. Objects should be unquoted and exist in the current session environment.

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
template <- make_template(
  "---\ntitle: Example\noutput: html_document\n---\n",
  "\nThe random number is `r random_number`.\n"
)
template <- use_parameters(template, "random_number")
pattern_file <- tempfile("out", tempdir(), ".Rmd")
export_template(template, pattern_file)

random_number <- rnorm(1)
if (rmarkdown::pandoc_available()) {
  rmarkdown::render(pattern_file, params = provide_parameters(random_number))
}

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