I'm currently making a presentation using Rstudio's R presentation functionality.
I have an algorithm which loops through and plots a graph every second or two.
The algorithm can be called via RunAlgorithm()
RunAlgorithm<-function(){
for(i in 1:10){
x<-rnorm(1000)
y<-runif(1000)
plot(x,y)
Sys.sleep(1)
}
}
I want to show this algorithm running in the presentation. But when I use it in the file (below), I just get a whole page of each individual plot, one displayed right after the next
TestFile.Rpres
TestFile
========================================================
author: me
date: today
First Slide
========================================================
```{r echo = FALSE}
RunAlgorithm<-function(){
for(i in 1:10){
x<-rnorm(1000)
y<-runif(1000)
plot(x,y)
Sys.sleep(1)
}
}
RunAlgorithm()
```
Slide With Code
========================================================
Slide 2
What I would like is some way to click a button, or turn onto this slide and have the animation play in browser