问题
I'm having a strange problem, that seems to be known (e.g. https://github.com/yihui/knitr/issues/408), but so far I haven't been able to find a solution.
The following code in R markdown should show a title, plot, title, plot, title, plot; instead, it shows two titles, a plot, a title, 2 plots. Anything I can do to fix it so that the correct titles show up with the right plots?
```{r, fig.height=2, fig.width=3, results='asis'}
for (i in 1:3){
cat('\n')
cat("#This is a heading for ", i, "\n")
hist(iris[,i])
cat(' \n\n')
}
```
来源:https://stackoverflow.com/questions/44595377/r-markdown-bug-when-displaying-plots-in-a-loop-with-headers