[R] warning.expression?

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Thu Sep 22 20:56:54 CEST 2005

> I'm afraid this does not make sense to me. An "interactive session" is 
> not some monolithic blob. It is a sequence of one or more (often very 
> many) discreet interactions. Any one of these may produce an 
> exceptional condition, and it seems to me that each individual 
> interaction that elicits an exception should be handled independently 
> and if it does produce an exceptional condition, that should be 
> reported as soon as it occurs. Things should then be cleaned up, as 
> necessary and feasible, and the interactive session should be allowed 
> to continue.

Sorry, indeed I was simplifying beyond recognition. Actually, I'm writing a 
GUI front-end to R, and what I called an "interactive session" is technically 
not an interactive session in R at all, but would only seem like one to the 
user. In the GUI, there are R expressions being run from some application 
code, but also there is a sort of console, where the user can interact with R 
more or less directly, like they would in a regular interactive session.
What I mean by "special handling", then, is not so much reacting to the 
warnings/errors. Rather, the thing I'm really trying to do, is just to figure 
out, which output is "regular" output, which is a warning, and which is an 
error. All output gets displayed right in time, for the user to react to. 
However, one use case would be to mark up all warnings in a certain color and 
all errors in another. Also, for commands running for GUI-actions, it would 
be nice to inform the user - if applicable - "there have been the following 
warnings" or "an error occurred, see below".
So basically, my programmer's dream would be to have three simple callbacks: 
one each for "regular output", warnings and errors. While it's not quite as 
simple, I have most things in place: I'm catching all that would be going to 
stdout via ptr_R_WriteConsole. I'm catching the errors using my own callback 
in options (error=...). Now all I need is a way to find out about warnings. 
It seemed to me, options (warning.expression=...) would be a neat way to do 
that, but I could not find out, how to use it.
Hope that clarifies what I need this for. BTW, the project in question is 
this: http://rkward.sf.net


More information about the R-help mailing list