Document
Parameters

Parameters

overview You may have a set of parameter that are used to create different variations of a document. For example: Showing results for a specific g

Related articles

4 Ways to Download WhatsApp Status Videos on Any Device Case Study Opera VPN for Netflix: Does it Work? How To Watch Netflix US Ultimate Guide Cloud Kitchen Setup Cost In India 2024 5 Best VPNs for TikTok

overview

You may have a set of parameter that are used to create different variations of a document. For example:

  • Showing results for a specific geographic location.
  • run a report that cover a specific time period .
  • Running a single analysis multiple times for different assumptions.

This article is describes describe how to define and use computational parameter with Quarto .

definition

Adding parameter definitions to a document works differently depending on whether you are using the Jupyter or Knitr engine.

Jupyter

For Jupyter, Quarto uses the same syntax for defining parameter as Papermill. To parameterize a document, designate a cell with the tag parameter and provide appropriate default value :

` ` ` { python }
#| tags: [parameter]

alpha = 0.1
ratio = 0.1
```

The parameter are available in the top level environment:

When the document is executed with a set of new parameter a cell is injected which overrides these defaults as appropriate.

Knitr

For Knitr, the standard Knitr params YAML option is used to define parameter. For example:

---
params:
  alpha: 0.1
  ratio: 0.1
---

The parameter are available in the params list:

Rendering

To render using different parameter you can pass them on the command line using the -P flag (this works for both .ipynb or .qmd files):

quarto  render document.ipynb-P  alpha:0.2-P  ratio:0.3

alternatively you is create can create a yaml file that define the parameter value you want to render with , then call quarto render with the--execute - params flag:

quarto render document.qmd --execute - params params.yml