The question was:
> 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?
Prof Brian D Ripley was the only one how responded (thanks) to the
original posting. His suggestion works perfectly for me, and his respond
follows:
############################
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.
##################
By the way; is it 'required' to write a summary of responses and post to
r-help? (e.g., as on the s-news list.)
Thanks,
Gardar
_________________________________________________________
Gardar Johannesson Home Addr.
Department of Statistics 605 Dennison, #3
Ohio State University Columbus, OH 43215
305A Cockins Hall, 1958 Neil Av. Tel: 614-531-0102
Columbus, OH 43210 ( cellular )
Tel: 614-292-6038
Fax: 614-292-2096
e-mail: gardar at stat.ohio-state.edu
WWW: www.stat.ohio-state.edu
_________________________________________________________
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._