Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to combine params and inline code in Quarto

In Quarto we can use R inline code and parameters from the YAML. I would like to combine them. Here is a reproducible example to combine inline code and parameters from the YAML:

---
title: "Params in inline code"
format: html
params:
  alpha: 2
---
       
This value is `{r} params$alpha`

Output:

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Apparently this doesn’t work. The parameters value doesn’t show in the inline code of the document. The parameters does work in a code chunk, but I would like to use this in a inline code to keep the document clean. So I was wondering if anyone knows how to combine parameters and inline code like above in a Quarto document?

>Solution :

For params you need to explicitly set the engine to knitr like this

---
title: "Untitled"
format: html
params:
  alpha: 2
engine: knitr
---

## Params inline code 

This values is `r params$alpha` 


using params with inline code chunks

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading