[R] logging mouse clicks

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Mon Mar 12 10:35:38 CET 2007


Seth Roberts wrote:
> How can I use R to record the time of a mouse click?

Assuming they are mouse clicks on a plot from locator() or identify() 
then its as trivial as this:

 > plot(1:10)
 > locator(1); when=date(); print(when)
$x
[1] 3.787584

$y
[1] 1.978947

[1] "Mon Mar 12 09:34:07 2007"

  but that only gets you one second resolution, and assumes zero delay 
between the click and the when=date() function call.

Good enough?

Barry



More information about the R-help mailing list