[R] Reflecting R-commands in command line
M.Kondrin
mkondrin at hppi.troitsk.ru
Sat Mar 6 04:50:47 CET 2004
Thank you for your replies. I will look into Rcmdr, of course, but not
in the moment.
I think about making some replacement of R edit() command with GTK toolkit.
I suppose what I would have a script where interface is stored. It is
either source()-d into R session or loaded as library and called with
command like gtkedit.start.gui() (so echo will not help because it works
only for non-interactive sessions). When I would edit some entries in
data.frame loaded into GUI table, the commands I use to change values of
data.frame is send into R-session. So if some errors are introduced into
the frame they can be tracked in R-session transcript and a rollback can
be done.
Here is an example of what I actually mean. This tkGUI just does an
assignment Rvar<-Rvalue, with Rvar and Rvalue are taken from entries in
tk window. The question is how the line evaluated in callback can be
reflected in command line? Sending the string to stdin() is impossible
as stdin is opened as read-only.
library(tcltk)
tclVar()->h
tclVar()->z
#set a callback for a button - glue togather string from first and
second entries with assignment operator, parse resulting string and
evaluate it. This string I want to be sent to R-session and somehow eval
it there.
.Tcl.callback(function(...){eval(parse(text=paste(tclvalue(h),"<-",tclvalue(z))),envir=.GlobalEnv)})->l
# The interface itself - Button and two entries.
.Tcl(paste("toplevel .0 ; grid [button .0.1 -text \"Set var\" -command
{",l,"}] [entry .0.2 -textvariable ",as.character(h),"] [entry .0.3
-textvariable ",as.character(z),"]"))
More information about the R-help
mailing list