[R] Automating an R function call

Duncan Murdoch murdoch.duncan at gmail.com
Fri Aug 12 21:26:30 CEST 2011


On 12/08/2011 2:03 PM, RobertJK wrote:
> Any way to run an R function every 5 minutes from the R terminal? Searched
> around but couldn't find any answers. Thanks!!

Yes, but not in the background:

repeat {
   f()
   Sys.sleep(300)
}

If you want it run in the background, get your OS to run R to do it.  
(It's possible the tcltk package will give you access to some tcl way to 
set a background process; I don't know.  Similarly, you could call out 
to C and start up another thread, etc., but R itself is single-threaded.)

Duncan Murdoch



More information about the R-help mailing list