Open sda030 opened 1 month ago
hello @sda030 I doubt output: asis
manage and collect htmldependancies as it is done via a classical print method.
This https://ardata-fr.github.io/flextable-book/rendering.html#looping-in-r-mardown-documents may help. See also the original documentation https://bookdown.org/yihui/rmarkdown-cookbook/child-document.html
PS : I am sorry, I can't spend time on that for now and provide you a tested solution :(
Oh, David, I would buy you a basket of assorted cheeses, croissants and wine, this simplified things a lot.
For anyone else wondering, it's as simple as this:
```{r}
#| panel: tabset
#| output: asis
data <- mtcars
lapply(unique(mtcars$cyl), function(x) {
knitr::knit_child(text = c(
'## Cyl: `r x`',
'',
'```{r}',
'library(ggplot2)',
'library(ggiraph)',
'girafe(ggobj=',
'ggplot(data[data$cyl == x, ], aes(x=mpg, y=hp, tooltip=mpg)) +',
'geom_point_interactive()',
')',
'```',
''
), envir = environment(), quiet = TRUE)
}) |> unlist() |> cat(sep = '\n')
:)
Note that this is not so much a cliché about me (with the exception of wine, which I avoid drinking during the week).
Quarto has a
#| panel: tabset
chunk option that is a very nifty shorthand way of producing multiple plots in tabs, without having to split up each chunk (which does work). This shorthand way works with ggplot, but not with ggiraph. Any idea for a workaround?ggiraph
works for single plotDoes not work with multiple plots (there is not even any intermediate md-output that I could fiddle to work)