title: R GUI Histogram menu. Error when clicking in variable list box
body: <p>As you know, I'm new in R and I'm trying to build a GUI. I've included a menu button to create a histogram. So the variables will be in a list box and when I chose the variable, the histogram should be made. The problem is that I'm getting the following error: <strong><em>"Error in hist.default: 'x' must be numeric"</em></strong>. What's wrong with my code????
  Could someone help me with that, please??? The code is below(updated).</p>
  
  <p>Thank you in advance!</p>
  
  <p>Now with updated code:</p>
  
  <pre><code>require(tcltk)
  tt &lt;- tktoplevel()
  tkwm.title(tt, "Window")
  tkgrid(tklabel(tt,text="Variables"))
  tl &lt;- tklistbox(tt,height=5,selectmode="single", background="white")
  scr &lt;- tkscrollbar(tt, repeatinterval=3, command=function(...) tkyview(tl,...))
  tkgrid(tklabel(tt,text="Choose one:"), tl, scr)
  
  dataframe &lt;- tclVar("myData")
  df &lt;- get(tclvalue(dataframe))
  vars &lt;- c(names(df))
  len &lt;- length(df)
  
  for (i in 1:len) tkinsert(tl,"end",vars [i])
  
  tkselection.set(tl,len)
  tkgrid(tklabel(tt, text = " "))
  
  tkgrid.configure(scr,rowspan=4,sticky="nsw")
  dfname = tclVar('myData')
  varname = tclVar()
  
  OnOK &lt;- function(...)
  {
    varchoice = vars[as.numeric(tkcurselection(tl))+1]
    hist(varchoice, col='blue')
  }
  
  OK.but &lt;-tkbutton(tt,text="   OK   ",command=OnOK)
  tkgrid(OK.but)
  tkfocus(tt)
  </code></pre>