Lowering the speed of a plot loop to see movements in R (without clicking)

89 Views Asked by At

I was wondering how I could lower the speed (i.e., the timing) of the for() loop below to allow plot changes to be visible and tangible by human eye in R (without having to click enter and just watching the looping run slowly)?

Here is a piece of R code:

for (i in 1:50) {

  plot(rnorm(40))
  readline(prompt="Press [enter] to continue")

}
1

There are 1 best solutions below

0
brb On BEST ANSWER
pauseLength = 4   # length of pause in seconds

for (i in 1:50) {
    plot(rnorm(40))
    Sys.sleep(pauseLength)
}