[R] locator() via tcltk

From: Sebastian Luque <spluque_at_gmail.com>
Date: Sat 04 Jun 2005 - 11:51:23 EST


I'm trying to write a function using tcltk to interactively modify a plot and gather locator() data. I've read Peter's articles in Rnews, the help pages in tcltk, http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/, plus a post in R-help sometime ago, but haven't found a solution. The idea goes something like this:

testplot <- function() {
  getcoords <- function(...) {
  x <- 1:1000
  y <- rnorm(1000)
  plot(x, y)
  base <- tktoplevel()
  loc.pts <- tkbutton(base, text = "Get coordinates", command = getcoords)   quit.but <- tkbutton(base, text = "Quit",

                       command = function() tkdestroy(base))
  tkpack(loc.pts, quit.but)

I'd like testplot to return the value from getcoords. The "Get coordinates" button seems to be correctly calling getcoords, and locator is doing its job, but I don't know how to store its value. Any help is very much appreciated.


Sebastian P. Luque

R-help@stat.math.ethz.ch mailing list
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Sat Jun 04 11:59:15 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:22 EST