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

Next Xbox 2025: everything we know about the Xbox Series X and S follow-up Best VPN Services for the USA With Servers in All 50 States Nextcloud Flow makes it easy to automate workflows and actions Download the Latest Free Base Apk for Whatsapp and Android What is a landing zone? (explained in 4 min)

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