use_parameters: Automatically include session objects as report parameters

Description Usage Arguments See Also Examples

View source: R/use_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 adding your objects to the YAML header and then initializing them so you can use the same object names in your generated document as in your generator.

Usage

1
use_parameters(template, ..., init.params = TRUE, is.file = FALSE)

Arguments

template

An atomic (length(template) == 1) character vector containing either the template to manipulate OR the path to the file storing the template, which will be imported via import_pattern.

...

Objects to be included as parameters. Objects should be unquoted and exist in the current session environment. This function currently will always assign parameters NA as a default value, and does not yet provide an option to override that.

init.params

A boolean (TRUE/FALSE) value indicating if a chunk initalizing the parameters (that is, assigning them via object <- params$object) should be included. Default TRUE.

is.file

A boolean value indicating if the template argument is a vector containing the template (FALSE, default) or the path to the template file (TRUE).

See Also

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

Examples

1
2
template <- make_template("---\ntitle: Cool Report\noutput: html_document\n---\n")
use_parameters(template, data)

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