-
DescriptionI am looping over a large table to print multiple extracts from the table, using Although I can manually insert two I've tried various combinations of I'm on quarto version 1.6.4 ---
title: "Multi-page gt table"
format: typst
---
# Renders correctly manually
```{r setup}
#| include: false
library(dplyr)
library(gt)
```
```{r}
#| echo: false
#| warn: false
mtcars |>
head() |>
gt()
mtcars |>
tail() |>
gt()
```
# Nothing renders in a loop
```{r}
#| echo: false
cyls <- unique(mtcars$cyl)
for (cyl in cyls) {
mtcars |>
filter(cyl == !!cyl) |>
gt()
}
```
# Setting `output: asis` with `print()` doesn't help
```{r}
#| echo: false
cyls <- unique(mtcars$cyl)
for (cyl in cyls) {
mtcars |>
filter(cyl == !!cyl) |>
gt() |>
print()
}
``` |
Beta Was this translation helpful? Give feedback.
Answered by
mcanouil
Aug 20, 2024
Replies: 1 comment 3 replies
-
In the order of the document:
For "complex R object" inside for loops in One answer/solution: |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
andrie
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the order of the document:
```{r setup}
is the "old way". In Quarto, prefer#| label: setup
."Nothing renders in a loop"
That'sknitr
/R behaviour. Everything inside a loop requires an explicitprint()
.For "complex R object" inside for loops in
knitr
you usually needknitr::knit_child()
/knitr::knit_expand()
.One answer/solution: