[R] timer in R?

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Jul 1 22:00:57 CEST 2009


On Wed, Jul 1, 2009 at 8:41 PM, Michael<comtech.usa at gmail.com> wrote:
> Hi all,
>
> How could I set a timer in R, so that at fixed interval, the R program
> will invoke some other functions to run some tasks?
>

 Use timer events in the tcltk package:

> z=function(){cat("Hello you!\n");tcl("after",1000,z)}
> tcl("after",1000,z)

 now every 1000ms it will say "Hello you!". I'm not sure how to stop
this without quitting R. There's probably some tcl function that
clears it. Maybe. Or not. Just make sure you don't *always* reschedule
another event on every event.

 Barry




More information about the R-help mailing list