The following model code
extensions [ sr ]
to setup
clear-all
sr:setup
sr:run "library(ggplot2)"
end
to ggplot
sr:set-plot-device
(sr:run
"df <- data.frame(x = rnorm(30), y = rnorm(30))"
"ggplot(df) + "
" geom_point(aes(x = x, y = y))"
)
sr:run "ggsave('~/Downloads/test.png')"
user-message "Plot will close when you close this dialog."
sr:run "dev.off()"
end
fails to show a plot in the on-screen plot window, although the expected ggplot shows up as the requested PNG file:

The user-message is my way to cleanly close plot devices - so don't worry about that part.
Is this some subtlety or R plotting, specifically in relation to ggplot that I don't understand? Or is it a problem with the Simple R extension? How do I do I to get an on-screen ggplot to show up?