I have a list of girafe objects, created using girafe() from the package ggiraph. These are essentially interactive ggplot objects.
I would like to loop over the list of girafe objects and print these plots in an rmarkdown file.
Using results = "asis" in the code chunk, my attempts have been along the lines of:
if ("chart.ls" %in% names(current)) {
for (i in seq_along(current$chart.ls)){
knitr::knit_print(current$chart.ls[[i]])
}
}
Further, the below code will print the plot as expected
if ("chart.ls" %in% names(current)) {
knitr::knit_print(current$chart.ls[[2]])
}
I understand there are alternative ways to print graphs from inside a loop, but these methods don't seem to work for interactive graphs.
Is there a way to print girafe objects from inside a loop, without using external packages? (e.g. knitrContainer)
I have a workaround, which is to use child Rmds. Where I can loop over the object, then reference a child.rmd which then prints it. But hoping for a real solution.