[R] tklistbox and extracting selection to R

Judith Flores juryef at yahoo.com
Tue Jul 22 18:40:31 CEST 2008


Dear experts,

   I am trying to understand why is it that when I paste (into the R console) the following code to select an option from a list:

  require(tcltk)
  tt<-tktoplevel()
  tl<-tklistbox(tt,height=ntx,selectmode="single",background="white")
  tkgrid(tklabel(tt,text="Select the legend of" ))
  tkgrid(tl)
  treatments<<-levels.tx
  for(i in (1:ntx))
  {
      tkinsert(tl,"end",treatments[i])
  }

  OnOK<-function()
  {
      tx.choice1<<-treatments[as.integer(tkcurselection(tl))+1]
      tkdestroy(tt)
        
  }
  OK.but<-tkbutton(tt,text="    OK    ", command=OnOK)
  tkgrid(OK.but)

tx.choice1


     the console can't find tx.choice1, but if I type tx.choice1 directly into the console, it returns the value I selected from the list.

   I am running R 2.7.1, OS: linnux, I run R within emacs.

Thank you very much for you help,

Judith



More information about the R-help mailing list