[R] tkbutton command - how to know which button was clicked?

From: JeeBee <JeeBee_at_troefpunt.nl>
Date: Sat 01 Jul 2006 - 03:42:13 EST

In the below code fragment, print(arg) always prints the last element of rekeningen$rekening.
Is this because of lazy evaluation? I.e. arg is evaluated at
the time the button is pressed?
And, if so, how can I avoid this?
I tried function() {force(arg); print(arg)} but that didn't work either.

Thanks,
Jeebee.

  for(rek in seq(1,nrow(rekeningen))) {
    arg <- rekeningen$rekening[rek]

    tkgrid(tkbutton(frame.1,

      text=paste("Saldo historie", arg),
      command=function() print(arg)),
      sticky="news")

  }

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 01 03:52:29 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 01 Jul 2006 - 10:14:02 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.