Open mcanouil opened 1 year ago
Thanks for reporting this Mickaël! I recall having problems with iteration and gt tables before in R Markdown. This might generarally have something to do with that. Will have a closer look at this soon.
I believe the issue is not specific to Quarto, as I am expecting the same thing within RMarkdown (knitr), but did not really tested it.
I simply discovered this when using Quarto since I do not use rmarkdown
anymore^^
I just stumbled across this issue while looking for something else. I now find myself with the following. If that helps in any way...
---
title: "Quarto and Interactive Tables"
format: html
---
```{r}
library(gt)
#| results: asis
#| echo: false
#| panel: tabset
for (i in 1:2) {
cat(sprintf("\n\n## Tab %s\n\n", i))
print(opt_interactive(gt(head(gtcars))))
}
No need for print()
in child doc. Works even if table gets longer (i.e., without head()
- what I found causing troubles in another situation).
With the part below, the above example from @mcanouil works, without it, it does not...!?
#| results: asis
#| echo: false
#| panel: tabset
purrr::walk(
.x = c(3:4),
.f = \(x) {
cat(sprintf("\n\n## Tab %s\n\n", x))
cat(
knitr::knit_child(
quiet = TRUE,
text = c(
"```{r}",
"#| results: asis",
"#| echo: false",
"opt_interactive(gt(gtcars))",
"gt(gtcars)",
"```"
)
)
)
}
)
Thanks, but if I put the explicit print()
, it is for a reason even if indeed you might omit it in this simple example.
Description
Using regular print or
knitr::knit_child()
tricks do not work to displaygt
tables whenopt_interactive
is used.Reproducible example
Static (working)