[R] tcltk - command=function()

chr.schulz@email.de chr.schulz at email.de
Thu Sep 26 23:16:17 CEST 2002


peter,

really thanks, that is  a big step - especially the tclvalue function 
and it works well - now i could extend as you mentioned ;-))

regard,christian


Peter Dalgaard BSA schrieb:

<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. 





-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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