[R] Timer in R?

M.Kondrin mkondrin at hppi.troitsk.ru
Tue Aug 12 02:23:50 CEST 2003


Jim Lemon wrote:
> Johnathan Williams wrote:
> 
> 
>>Would anyone be so kind as to write a routine to time 
>>mouse button presses in R to the nearest millisecond?
>>
>>If R had a timer of this kind and a few basic screen
>>handling routines (to write characters or graphics of
>>different sizes and colours at precise times) then it
>>would make it easy to use it for on-line data analysis
>>of data to control EEG experiments.
> 
> 
> I do this under DOS for a battery of human performance tests. However, it 
> requires taking over the system clock _and_ the keyboard interrupt to time 
> keypresses to the nearest millisecond (and you can get a bit more than 
> that if you want). If anyone knows about how to do this under Linux, I 
> would love to port these tests over.
> 
> Jim
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 
> 

You can use (for example) RGtk library (from Omegahat). Then compose
some sort of test pad where user would click buttons. Gdk events  have a
field "time" (in milliseconds) and all you have to do is to attach
callback for specific X-events.
Sample R callback (to intercept mouse button clicks):

mouse.button.hit<-function(win, arg) {
MouseButtonPressTime<<-as.numeric(gdkEventButtonGetTime(arg))
}




More information about the R-help mailing list