Re: [R] 'pausing' in R

About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [R] 'pausing' in R
From: Prof Brian D Ripley (ripley@stats.ox.ac.uk)
Date: Thu 22 Jun 2000 - 17:23:49 EST


Message-ID: <Pine.GSO.4.05.10006220812440.21103-100000@auk.stats>

On Wed, 21 Jun 2000, Gardar Johannesson wrote:

>
>
> I have this 'odd' problem; I need to let R pause, for a given time, before
> starting next iteration in a loop. I'm using the following to do this
> task, but feel a little bit guilty because I'm using as much CPU time as I
> can get while pausing:
>
> while(keepGoing) {
> t.end <- proc.time()[3] + 5 ## the time this loop should end at
>
> [block of R commands]
>
> while(proc.time()[3] < t.end) {}
> }
>
> This guaranty, at least, 5 second evaluation time for each loop in the
> above case.
>
> Can I delay the loop more efficiently, that is, not using as much CPU time
> as in the above case?

Try

system("sleep 5")

That will use essentially no CPU time, but it will block the process.
That stops re-sizing graphics windows for examples, but on Unix
is not too serious. I am not sure of the effect on the GNOME console,
nor what happens if tcltk is running.

If anyone wants to do this on Windows. take a look at the xgobi
function in the current version of the XGobi package, as that package
has an equivalent in C (that does handle events during the pause).

We do plan to have a version of this for all platforms in due course.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b25 : Mon 17 Jul 2000 - 12:33:24 EST