I'm using an external JSON file to store the text that is being used in a Quarto document. This JSON file is being read in and then I'm using it to populate the text. I'd like to embed R code in the strings similar to what you can do with bare text in Quarto surrounded by tic marks.
Can this be done where the R code is executed
{
"about": {
"title": "The mean is `r mean(1:5)`"
}
}
```{r}
info <- jsonlite::read_json("report_text.json")
```
This works but I am not using the JSON: The mean is `r mean(1:5)`
This does not work, this is what I want to do: `r info$about$title`
```{r, results='asis'}
# This does not work either
cat(info$about$title)
```
You can use knitr::knit_child
to parse chunks of text
```{r, results='asis', echo=FALSE}
cat(knitr::knit_child(text=info$about$title, quiet=TRUE))
```