R/use_parameters.R
use_parameters.Rd
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.
use_parameters(template, ..., init.params = TRUE, is.file = FALSE)
template | An atomic ( |
---|---|
... | 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 ( |
is.file | A boolean value indicating if the template argument is a
vector containing the template ( |
Other manipulation functions:
create_yaml_header()
,
heddle()
,
make_template()
,
provide_parameters()
template <- make_template("---\ntitle: Cool Report\noutput: html_document\n---\n")
use_parameters(template, data)
#> [1] "---\ntitle: Cool Report\noutput: html_document\nparams:\n data: NA\n---\n```{r}\n\ndata <- params$data\n```\n\n"