[R] console from tcltk

John Fox jfox at mcmaster.ca
Wed May 14 18:00:37 CEST 2008


Dear Brian and Gabor,

When the Rcmdr "console.output" option is set to TRUE, the Rcmdr interface
does something very much like this using cat() for R output, which it
captures. The relevant code is in the doItAndPrint() function in the Rcmdr
sources.

I hope this helps,
 John 


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On
> Behalf Of Prof Brian Ripley
> Sent: May-14-08 11:10 AM
> To: Gabor Grothendieck
> Cc: R help forum
> Subject: Re: [R] console from tcltk
> 
> I assume by 'console' you mean the Rgui window.  That is not where stdout
> is connected -- it is not a file.  As the CHANGES file for 2.7.0 says
> 
>      o   When Rgui is launched from a terminal, C output from ill-formed
>          packages that write to stdout or stderr rather than use
>          Rprintf will appear in the terminal rather than being lost.
>          (Only on XP or later.)  This can be very handy for debugging C
>          code in packages: just write debugging messages to stdout.
> 
> And indeed that is what your example does.  It also writes to the terminal
> from Rterm.
> 
> Tcl is no different from any other C-based add-on in this respect.
> 
> Note though that system() does provide a way to capture stdout to the Rgui
> window, so you can probably run tcl scripts via the tcl shell and capture
> their output.
> 
> On Tue, 13 May 2008, Gabor Grothendieck wrote:
> 
> > Is it possible to use the console from within tcltk?
> >
> >> library(tcltk)
> >> tcl("puts", "stdout", "Hello, World")
> > Error in structure(.External("dotTclObjv", objv, PACKAGE = "tcltk"),
> > class = "tclObj") :
> >  [tcl] can not find channel named "stdout".
> >> .Tcl('puts stdout "Hello, World"')
> > Error in structure(.External("dotTcl", ..., PACKAGE = "tcltk"), class
> > = "tclObj") :
> >  [tcl] can not find channel named "stdout".
> >> R.version.string  # Windows Vista
> > [1] "R version 2.7.0 RC (2008-04-17 r45367)"
> 
> Oh dear, not even the released version!  Please update as the posting
> guide asked you to do before posting.
> 
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> 
> --
> 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
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list