Are you looking for options(echo=TRUE)? Otherwise we need to know more about how your GUI is submitting R code. On Fri, 5 Mar 2004, M.Kondrin wrote:> Somewhat strange question. > Suppose I have some sort of GUI. Clicking for example button in it I > expect some R-commands to be executed in R. But I want this commands to > be logged into R command line and the output printed there too (I want > to save this later in transcript file). How this can be done?-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Dear M. Kondrin, If your GUI is written with the tcltk package, then you might take a look at the Rcdmr package, which does approximately what you describe. You should be able to adapt the approach taken there. I hope that this helps, John> -----Original Message----- > From: r-help-bounces+jfox=mcmaster.ca at stat.math.ethz.ch > [mailto:r-help-bounces+jfox=mcmaster.ca at stat.math.ethz.ch] On > Behalf Of M.Kondrin > Sent: Friday, March 05, 2004 7:48 PM > To: R-Help > Subject: [R] Reflecting R-commands in command line > > Hello! > Somewhat strange question. > Suppose I have some sort of GUI. Clicking for example button > in it I expect some R-commands to be executed in R. But I > want this commands to be logged into R command line and the > output printed there too (I want to save this later in > transcript file). How this can be done? > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html
Hello! Somewhat strange question. Suppose I have some sort of GUI. Clicking for example button in it I expect some R-commands to be executed in R. But I want this commands to be logged into R command line and the output printed there too (I want to save this later in transcript file). How this can be done?
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),"]"))