0

How to fill a combo box with numbers like 2,3,4,5 ,when the user select the number , after that a button coded with clustering will take the value from the combo box to do the selected number of clustering.

Need help .

  • Please clarify your question, include some code and have a look at [**How to make a great R reproducible example**](http://stackoverflow.com/q/5963269) – BenBarnes Jan 08 '14 at 10:19
  • Great that it's solved! If you would like, you can post the solution below as an answer and accept it. If you'd prefer not to, please consider removing the question. – BenBarnes Jan 09 '14 at 11:12
  • 1
    tbl[2,3] =gedit("", container=tbl, coerce.with=as.numeric) . Through this code i had asked the user to enter how many cluster thy want to enter. Then i had called them in a function of a button cl1=clara(ssv,svalue(tbl[2,3])) ,to do the clustering. – user3155995 Jan 09 '14 at 13:10
  • Hay Ben can u suggest me where to find a easier codes to understand R ,for making a GUI or anything . I m 1 month old in R ,so my company asked me to create a Clustering tool . – user3155995 Jan 09 '14 at 13:16
  • For a while, I was using Tcl/Tk (good examples at http://www.sciviews.org/_rgui/tcltk/index.html). Recently, I've been delving into [Shiny](http://www.rstudio.com/shiny/) for browser-based interactive analyses with R. Good luck! – BenBarnes Jan 09 '14 at 14:37
  • Well thanks for it Ben , well Shiny seems to be web based ,so dont thnk it will help be mre .............do u have sumthng related to r gwidgetsrgtk ........... – user3155995 Jan 10 '14 at 05:28

1 Answers1

2

In case someone wants an answer, here is a sketch using gWidgets2:

w <- gwindow()
g <- gvbox(cont=w)
e <- gedit("5", cont=g, coerce=as.integer)
cb <- gcombobox(1:5, cont=g)
b <- gbutton("do clustering", cont=g)

addHandlerChanged(e, handler=function(h,...) {
  ## check svalue(e) is non-NA
  cb[] <- seq_len(svalue(e))
})

addHandlerClicked(b, handler=function(h,...) {
  print(sprintf("Do clustering with %s", svalue(cb)))
})
jverzani
  • 5,600
  • 2
  • 21
  • 17