[R] Loop Delaying

ben@zoo.ufl.edu ben at zoo.ufl.edu
Mon Jul 31 15:08:49 CEST 2000


  A few possibilities:

  1. if you're on a Unix system you can say something like 
system("sleep 5") to delay for 5 seconds.

  2. you can set par(ask=TRUE) to have R pause and ask you to hit ENTER
between each new plot.

  3. you can do a classic "delay loop" (for i in 1:10^6 {}) inside the for
loop.

  4. rather than pausing and (I guess) manually saving each plot to a
file, why not write them out to separate files using dev2bitmap() or png()
(or something) within the loop?  (e.g.  png(paste("outgraph.",i,sep="")) )
?

On Mon, 31 Jul 2000, Ko-Kang Wang wrote:

> Hi there,
> 
> I know this question may sounds strange, but here it goes:
> 
> Is it possible to delay the speed of a for loop?  For example, if I
> have:
> 
> for (i in 1:100) {
>     blah blah blah
> }
> 
> within the for loop I want to draw a series of plots, and combining the
> plots together I'll have an animation.  Problem is the loop is too fast
> and I only see the end result (which is not surprising actually).
> 
> What I want is to slow down the loop (if possible), and so I have time
> to save each "part" of the loop (or each plot when it is produced) as a
> gif file, and later on put these gif files together using some kind of
> GIF Animators.
> 
> Anyway, just wonder if the for loop can be slowed down forcebly.
> 
> Cheers,
> 
> Ko-Kang (Kevin) Wang
> 
> 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list