R/provide_parameters.R
provide_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 automatically creating a named list from provided objects rather than requiring a named list. This function is a stripped-down variant of [tibble::lst].
provide_parameters(...)
... | Objects to be included as parameters. Objects should be unquoted and exist in the current session environment. |
---|
Other manipulation functions:
create_yaml_header()
,
heddle()
,
make_template()
,
use_parameters()
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))
}
#>
#>
#> processing file: out8c2252687a89.Rmd
#>
|
| | 0%
|
|....................... | 33%
#> ordinary text without R code
#>
#>
|
|............................................... | 67%
#> label: unnamed-chunk-1
#>
|
|......................................................................| 100%
#> inline R code fragments
#>
#>
#> output file: out8c2252687a89.knit.md
#> /usr/bin/pandoc +RTS -K512m -RTS out8c2252687a89.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output out8c2252687a89.html --lua-filter /home/runner/work/_temp/Library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/runner/work/_temp/Library/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --variable bs3=TRUE --standalone --section-divs --template /home/runner/work/_temp/Library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable theme=bootstrap --include-in-header /tmp/RtmpJ4SLiP/rmarkdown-str8c22483c3db.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
#>
#> Output created: out8c2252687a89.html