R – Generate multiple plots in R markdown

rr-markdownrstudio

I want to make automatic report in R Markdown with multiple similar plots. I have a list which contains some similar data frames. I need a separate plot in output for each data frame. The main problem is that I need to reproduce this report with different conditions and length of the list can be different. I tried this solution:

for (i in 1:length(list.of.dfs)) {
plot(list.of.dfs[[i]])
}

But it didn't work.

Best Answer

(Can't post graphics in comments…not necessarily suggesting this is an answer)

The following:

---
output: html_document
---

```{r}
mtcars_list <- list(mtcars, mtcars, mtcars)
for (i in seq_along(mtcars_list)) {
  plot(mtcars_list[[i]], main=i)
}
```

produces:

enter image description here

Please check your data and/or provide a reproducible example.