Escaping inline R chunks

New Quarto-style inline chunks

Quarto uses this syntax for inline chunks, with the language name wrapped in curly braces

The value of π is `{r} round(pi, 2)`

↑ that renders to this ↓

The value of π is 3.14

To show the inline code verbatim, either wrap the {r} in double braces:

`{{r}} round(pi, 2)`{r} round(pi, 2)

Or wrap the expresion in an extra set of backticks:

``{r} round(pi, 2)``{r} round(pi, 2)

Old {knitr}-style inline chunks

{knitr} uses this syntax, without the {}s around the r:

The value of π is `r round(pi, 2)`

↑ that knits to this ↓

The value of π is 3.14

To show the inline code verbatim, see the R Markdown Cookbook. I find it easiest to use knitr::inline_expr(), which will build the escaped expression for you automatically:

`r knitr::inline_expr("round(pi, 2)")``r round(pi, 2)`