[R-gui] Small annoyance while interacting with R

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Mon Oct 24 17:36:25 CEST 2005


Hi,

> I'm trying to write some program in Ruby to interact with the R console but
> it doesn't work : in short, I can connect R standard input, output and
> error and retrieve correct calculations for correct inputs, but as soon as
> R writes something to the standard error, the program exits.

this is from memory, and may not be entirely correct, but roughly it's this:
If R notices it is not connected to a PTY, it goes into scripting/batch mode 
(i.e. interactive () == FALSE). This means, it will exit on any error. As far 
as I recall, this behavior cannot be changed, or at least not easily so.
A way to work around this is to embed R:
http://stat.ethz.ch/R-manual/R-devel/doc/manual/R-exts.html#Linking-GUIs-and-other-front_002dends-to-R
then set R_ConsoleFile = NULL, and override ptr_R_WriteConsole (Linux) or 
Rd->WriteConsole to point to your own function to handle output.
Several slightly different solutions are possible, but the key is to avoid 
having R go into batch mode.

Regards
Thomas Friedrichsmeier



More information about the R-SIG-GUI mailing list