[R-gui] Directing R output to a text window
James Wettenhall
wettenhall at wehi.edu.au
Fri Jun 4 16:51:08 CEST 2004
Edo,
> about what the program is doing. To resolve this, I would like to direct the
> R output the scripts generate to a text window. Does anyone know how to do
You may run into some of the problems described by Luke
Tierney's "Threading and GUI Issues for R" :
http://www.stat.uiowa.edu/~luke/R/thrgui/thrgui.pdf
But you can do something like this:
data(airquality)
txt <- capture.output(print.data.frame(airquality))
# See ?capture.output for more details.
library(tcltk)
tt <- tktoplevel()
txtWidget <- tktext(tt)
tkpack(txtWidget)
tkinsert(txtWidget,"end",paste(txt,collapse="\n"))
i.e. the output of print.data.frame(airquality) which would
normally be directed to the R console is now directed into the
text widget.
If the reason you don't want to use the R Console for output is
that you are using Windows and you find that RGui "steals the
focus" from Tcl/Tk, then you can solve this by selecting :
Edit, GUI Preferences, SDI (Single Document Interface mode),
then click Save to save your RGui configuration preferences
and then restart R.
Regards,
James
--------------------------------------------------------------------------
James Wettenhall Tel: (+61 3) 9345 2629
Division of Genetics and Bioinformatics Fax: (+61 3) 9347 0852
The Walter & Eliza Hall Institute E-mail: wettenhall at wehi.edu.au
of Medical Research, Mobile: (+61 / 0 ) 438 527 921
1G Royal Parade,
Parkville, Vic 3050, Australia
http://www.wehi.edu.au
More information about the R-SIG-GUI
mailing list