Skip to content

Commit

Permalink
Added external params example
Browse files Browse the repository at this point in the history
  • Loading branch information
royfrancis committed Oct 7, 2023
1 parent 502fcfb commit cc3d2e1
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
51 changes: 51 additions & 0 deletions documents/param-text/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: "Parameterized report"
description: "Report with parameterized text/code from external yaml"
author: "Roy Francis"
date: 08-Oct-2023
format:
html:
title-block-banner: true
theme: pulse
highlight: kate
code-tools: true

params:
dfr: virginica
---

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

```{bash}
#| eval: false
#| filename: params.yml
dfr: "setosa"
```

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

```{bash}
#| eval: false
#| filename: metadata.yml
section: "Section A"
block: "This is 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 as such

`quarto render index.qmd --execute-params params.yml --metadata-file metadata.yml`

## {{< meta section >}}

{{< meta block >}}


The `r params$dfr` species is subsetted from the data.

```{r}
#| filename: R
head(subset(iris, iris$Species == params$dfr))
```

2 changes: 2 additions & 0 deletions documents/param-text/metadata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
section: "Section A"
block: "This is the first part of the analysis."
2 changes: 2 additions & 0 deletions documents/param-text/params.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dfr: "setosa"

0 comments on commit cc3d2e1

Please sign in to comment.