-
Notifications
You must be signed in to change notification settings - Fork 636
Closed
Description
Hi there,
The problem is that I want to use a for loop to plot a bunch of interactive ggplotly graphs, which are put into corresponding slides one by one. I've check the issues #273, #425 and #570, but I still can't solve it.
The fail part of script in my.Rmd
file is:
---
title: "Automated slides"
output: ioslides_presentation
---
```{r, echo = F, message = FALSE, results='asis'}
### failed
library(plotly)
plt <- htmltools::tagList()
for(j in 1:2) {
cat(paste("\n\n## Feature: ",j),"\n\n" )
df <- data.frame(x = 1:10, y = (1:10)^2)
p <- ggplot(df, aes(x = x, y = y)) + geom_line()
plt[[j]] <- ggplotly(p)
}
plt
This is the expected one without a for loop:
### expected
plt <- htmltools::tagList()
for(j in 1:2) {
p <- ggplot(df, aes(x = x, y = y)) + geom_line()
plt[[j]] <- ggplotly(p)
}
cat(paste("\n\n## Feature: ",1),"\n\n" )
plt[[1]]
cat(paste("\n\n## Feature: ",2),"\n\n" )
plt[[2]]
Any ideas to solve the failed part? Thanks.
Metadata
Metadata
Assignees
Labels
No labels