R Markdown bug (?) when displaying plots in a loop with headers

丶灬走出姿态 提交于 2020-01-07 06:36:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!