Skip to content

Instantly share code, notes, and snippets.

@AdriMarteau
Created March 14, 2012 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdriMarteau/2034867 to your computer and use it in GitHub Desktop.
Save AdriMarteau/2034867 to your computer and use it in GitHub Desktop.
timer in R
if (!require("tcltk2")) install.packages("tcltk2")
RUNNING <- F
timer.freq <- 1000 #in ms
timer.pause <- function() {RUNNING <<- F}
timer.start <- function() {RUNNING <<- T}
timer.init <- function()
{
tclTaskSchedule(timer.freq, timer.tick_meta(), id = "TIMER", redo=T)
RUNNING <<- F
}
timer.stop <- function() {tclTaskDelete("TIMER"); RUNNING <<- F}
timer.tick_meta <- function()
{
if(!RUNNING) return()
timer.tick()
}
timer.tick <- function() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment