-
I tried different things, how to programmatically create child code cells and evaluate those child within Quarto? (My use case is a bit more complicated and related to #2088). The following does not work for instance.
It produces the following md file: ---
title: "Untitled"
format: html
keep-md: true
---
```{r}
#| eval: true
#| echo: true
1 + 1
plot(1)
``` while I would have liked to have: ---
title: "Untitled"
format: html
keep-md: true
---
::: {.cell}
```{.r .cell-code}
1 + 1
```
::: {.cell-output .cell-output-stdout}
```
[1] 2
```
:::
```{.r .cell-code}
plot(1)
```
::: {.cell-output-display}
{width=672}
:::
::: The actual use case Quarto document
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 10 replies
-
What is exactly the aim of this ? Your full for R document, the knitr way can still be done. With R Markdown it can be possible using recipies from Cookbook which would work for Quarto as they are knitr supported.
Basically what is missing in your example is the computation engine processing (here knitr processing) that creates the results from your including code chunk inside code chunk. ---
title: "Untitled"
format: html
keep-md: true
---
```{r}
#| echo: false
#| output: asis
child <- knitr::knit_child(text = c(
"```{r}",
"#| eval: true",
"#| echo: true",
"1 + 1",
"```"), quiet = TRUE
)
cat(child, sep = "\n")
```
````
Usually, using `child` chunk option with a child document is a cleaner way to go. Include shortcode in Quarto should be the equivalent of that. |
Beta Was this translation helpful? Give feedback.
What is exactly the aim of this ? Your full
.qmd
example seems a bit complicated to generated all this programmatically.Using an include file seems the way to go with Quarto. I think #2088 is more about issues in our supported feature, or regression from recent updates. Anyway, about your direct question see below.
for R document, the knitr way can still be done. With R Markdown it can be possible using recipies from Cookbook which would work for Quarto as they are knitr supported.
Those two recipies are about programmatically create content for the document leveraging