Parameterized report

Report with parameterized text/code from external yaml
Author

Roy Francis

Published

October 8, 2023

In this parameterized report, code parameters are specified in an external yaml file named _params.yml.

_params.yml
dfr: "setosa"

Text metadata is specified in an external yaml file named _metadata.yml.

_metadata.yml
topic: "Topic A"
block: |
  This is a multiline block. the first part of the **analysis**. More information. bla bla.

index.qmd is this file. See code-tools icons at the top of this document to see the code.

The document is rendered in the following ways:

# uses default params declared in the qmd yaml
quarto render index.qmd

# uses params defined in _params.yml
quarto render index.qmd --execute-params _params.yml

# uses params defined in _params.yml and merges metadata from _metadata.yml
quarto render index.qmd --execute-params _params.yml --metadata-file _metadata.yml

Topic A

This is a multiline block. the first part of the analysis. More information. bla bla.

The virginica species is subsetted from the data.

R
head(subset(iris, iris$Species == params$dfr))
    Sepal.Length Sepal.Width Petal.Length Petal.Width   Species
101          6.3         3.3          6.0         2.5 virginica
102          5.8         2.7          5.1         1.9 virginica
103          7.1         3.0          5.9         2.1 virginica
104          6.3         2.9          5.6         1.8 virginica
105          6.5         3.0          5.8         2.2 virginica
106          7.6         3.0          6.6         2.1 virginica