[R] warnings details
murdoch at stats.uwo.ca
Sat Oct 24 12:28:15 CEST 2009
Erich Neuwirth wrote:
> I am running R as an invisible subprocess in another program (RExcel).
> Using try I can catch errors and print the errors produced by an R
> Is there a way to know if running a statement caused a warning message?
> last.warning gives me the last warning, but I do not have any indication
> what the statement was that caused the message.
> I can of course store last warning before I run
> a statement and then compare last.warning with this stored message
> to see if it has changed, but that is
> a) clumsy
> b) still does not cover situations when I get the same warning
> as the last one by coincidence.
You could clear the old message by issuing your own warning, e.g.
warning("Cleared warnings in RExcel")
save.warning <- last.warning
... do something ...
if (!identical(last.warning, save.warning))
Working at a lower level, the R_WriteConsoleEx function tells a GUI
whether it is writing a regular message or a warning/error, so you could
keep track of that if you're working at that level.
More information about the R-help