I'm building a report using R Markdown and the output is a PDF document. The report summarizes some data - tables & figures - by various states. I want to the output to be formatted so that all of the tables/figures for each state appear on a different page. But the states included in the report is not fixed. Any ideas how to go about this?
Sample code below. In the example code, I'd want one page per species.
``` {r echo = FALSE}
for (i in temp_species) {
iris %>%
filter(Species == i) %>%
ggplot() +
geom_density(aes(Sepal.Length)) -> plot_1
iris %>%
filter(Species == i) %>%
ggplot() +
geom_density(aes(Sepal.Width)) -> plot_2
print(plot_1)
print(plot_2)
}
```