R Markdown (?) When displaying graphs in a loop with headers

I have a strange problem that seems to be known (e.g. https://github.com/yihui/knitr/issues/408 ), but so far I have not been able to find a solution.

The following code in R markdown should contain a title, graph, title, graph, title, plot; instead, he shows two titles, plot, headline, 2 plots. Is there anything I can do to fix this so that the correct headers appear with the correct graphs?

```{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') } ``` 

enter image description here

0
source share

Source: https://habr.com/ru/post/974443/


All Articles