[R] tcltk - command=function()

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Thu Sep 26 22:16:22 CEST 2002


<chr.schulz at email.de> writes:

> hi,
> 
> just having the idea create a simple
> tcl/tk gui-dialog for different data-file formats
> i get starting problems and it would be nice
> get some tips/tricks from experienced tcl/tk user in R !
> 
> tt <- tktoplevel()
> label.widget  <- tklabel(tt,text="Decision Tree GUI")
> button.widget <- tkbutton(tt,text="Select SPSSFile",
> command=function()  read.spss("C:/Cummulative/data/wekaSpecial.sav",
> use.value.label=T,to.data.frame=T))
> tkpack(label.widget,button.widget)
> tkdestroy(tt))
> 
> 
> ....how i have to use  command=function()  that this works like
> cat command ( i get no error message but nothing happen),or better
> how can i replace it with  tkgetOpenFile and do than an assignment 
> to a read.table,read.delim or read.spss command ?
> 
> i experiment with deparse and substitute, but get no success !

You'll need something a bit more elaborate, and possibly a little more
experience with R programming in general. I'd try omething like

getfile <- function() {
        name <- tclvalue(tkgetOpenFile(filetypes=
          "{{C files} {.c}} {{All files} *}"))
        if (name == "") return;
        zz <- read.spss(name, use.value.label=T, to.data.frame=T)
        assign("myData", zz, envir = .GlobalEnv)
}

button.widget <- tkbutton(tt,text="Select SPSSFile", command=getfile)

Obviously, you might want to extend this with a way to specify a
different name for the file, error checks, actual analyses, and so
forth. 


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list