|
This is related Q to #452 . Is it generally possible to have inline R code in YAML? It worked in RMarkdown. I can't get it to work using either |
Replies: 6 comments 18 replies
|
When using the YAML syntax for chunk option using You'll need last version of Quarto and also it requirees dev version of knitr as we have fixed an issue with this recently. |
|
@jjallaire with rmarkdown it is possible to use knitr execution to set some YAML field value programatically for Pandoc to read. Example in https://bookdown.org/yihui/rmarkdown-cookbook/dynamic-yaml.html, either using inline R code or params With Quarto we can't do exactly the same as R is only use as computation engine but is there any equivalent mechanism to set title using parameters when generating several reports for example ? Only solution I se and mentioned above is setting metadata using |
|
You can also pass |
|
For future generations: from all the discussion above I'm distilling that the metadata in the YAML document header (
Is the above a fair summary @cderv @jjallaire ? |
|
Has there been any more recent development to enable using parameters in the YAML header? Based on this discussion and this related stack overflow question I tried the following to no avail (using |
|
Hi @cderv, thanks for your reply. The use of In terms of my use cases: for data science projects, I set up exploratory data analysis reports which get run under various settings (e.g. changing the outcome variable, the data set (version) used, the filter settings) and like to see that reflected in the (sub)title of the report for immediate reference. Likewise, I build many different models and use the same reporting template for model evaluation. Elaborating on the latter with some code, using R and R markdown, I would run for example: rmarkdown::render(
here("code", "freq-model-evaluation.Rmd"),
output_file = glue(here("output", "html", "freq-model-evaluation-{model}-{version}.html")),
params = list(
actual = "claim_number",
modelled = "modelled_freq",
exposure = "exposure",
model = "gbm",
version = 1
),
envir = new.env()
)And the YAML header in my ---
title: "Frequency modelling"
subtitle: "`r paste('Model evaluation for', params$model, 'version', params$version)`"
---I'm now trying to set up a similar workflow in Python and Quarto. Based on the |


For future generations: from all the discussion above I'm distilling that the metadata in the YAML document header (
title,author,date,descriptionetc.)...`r 1 + 1`but is ignored. YAML fields are not passed through knitrmetadataobject in rmarkdown, c.f. this)qmdfile-M, e.g.quarto render file.qmd -M title:"New title". The-Mis apandocoption.--metadata-filebut that does not seem…