rmarkdown-book
rmarkdown-book copied to clipboard
Improve examples for parametrized report
This is not an issue, but a recommendation.
I would like to suggest that in the docs available in the Rmarkdown book you include two examples in chapter 15 (parameterized reports):
- passing parameters as raw markdown text for the parameterized reports.
- setting the title using a parameter
This information is available in other parts of the book, but I think including them there would make easier for other people starting to create report templates.
For example, something as such in the .Rmd
file:
---
output: html_document
params:
author: author
date: !r lubridate::today()
set_title: title
obs: my_text_chunk_with_markdown
title: "`r params$set_title`"
---
This is my parameter with markdown in a chunk:
```{r, results='asis', echo=FALSE}
cat(params$obs)
```
This is my parameter with markdown with code inline: `r paste(params$obs)`.
and something as such for the script that renders it:
rmarkdown::render(
path_to_file,
params = list(
set_title = 'title',
author = 'author',
obs = 'This is a text with *markdown* syntax.',
),
output_file = 'my_report.html')
)
For reference, we have added an example about setting the title dynamically in https://bookdown.org/yihui/rmarkdown-cookbook/dynamic-yaml.html
I'll move the issue to the rmarkdown book