wrong order of ggplot2 figures from a for loop in an Rmarkdown chunk

I've come across a strange Rmarkdown / ggplot2 interaction:

---
title: "Wrong order of ggplot figures from a loop"
output: html_notebook
---

For i > 3 this chunk does not keep the figues in the correct order:

```{r}
library(ggplot2)
for (i in 1:4)
{
  p <- ggplot(data = mpg) + 
    geom_point(mapping = aes(x = displ, y = hwy)) +
    ggtitle(i)
  print(p)
}

```

R 3.5.0, RStudio 1.1.463, all packages updated to the latest version

Can anyone else reproduce this?

Yes, I can reproduce your issue on Rstudio 1.2.1291, R 3.5.2, but I have no idea why this is happening.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.