Does the R language have any easy way to set-up a timer function ? By a timer function, I mean a function that sits in the background of the session and executes every so often.
Cheers!
Does the R language have any easy way to set-up a timer function ? By a timer function, I mean a function that sits in the background of the session and executes every so often.
Cheers!
In the tcltk2
package is the tclTaskSchedule
function (and others) that could be used to do what you want. Be warned that this will usually violate the idea of functions not having side effects and you can really mess things up if the scheduled function uses any of the same objects that you are working with. It would be fine if the task just read data into a local variable and plotted the latest version (just make sure that it plots to the correct graphics device and does not mess up something else you are working on).
If you just want something to update on a regular basis you could use a repeat
loop (or while
) and Sys.sleep to wait the given time, then do whatever you want. You would not be able to use that R session for anything else, but you can easily have multiple R sessions running at the same time so that would not prevent you from working in another R session.