DeaR list,
I am writing a user friendly script for an interactive use of R. The user is
supposed to click on a bat-File in Windows-environment and to enter some
values in a pop-up window.
Let us assume we have the script given below. If she sources this script
within R, everything works smoothly. The pop-up window jumps and patiently
waits her to enter the value. For this to work she has to start R, navigate
to File --> Source R code... and to find her R-Script file (or whichever we
sources the file). I want the things to be a bit more automatic - a single
click and everything goes. Let us assume the script lives in "test.R".
I
made the bat-Files with the following entries:
"D:\Program Files\R\R-2.9.1\bin\Rscript.exe"
test.R
or another bat file like this one
"D:\Program Files\R\R-2.9.1\bin\Rcmd.exe" BATCH test.R
Both of them seem to work, but they simply execute the
"test.R"-without
waiting the user to enter anything. I see the window popping-up and being
immediately closed afterwards. I tested almost every binary in
"...\R\R-2.9.1\bin\..." (Rcmd.exe, R.exe, Rterm.exe, Rscript.exe,
etc). In
case I made myself clear, could someone give me a hint of how accomplish
this task.
Cheers,
AS
############ BEGIN R Scipt ############
require(tcltk)
tt <- tktoplevel()
tktitle(tt) <- "My Schedular"
Name <- tclVar("")
entry.Name <-tkentry(tt,width="18",textvariable=Name)
tkgrid(tklabel(tt,text="Please enter your name"))
tkgrid(entry.Name)
OnOK <- function() {
NameVal <- tclvalue(Name)
tkdestroy(tt)
msg <- paste("You have a nice name",NameVal)
tkmessageBox(title="Result",message=msg)
}
}
OK.but <-tkbutton(tt,text=" OK ",command = OnOK)
tkbind(entry.Name, "<Return>",OnOK)
tkgrid(OK.but)
tkfocus(tt)
############ END R Scipt ############
[[alternative HTML version deleted]]