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
statement.
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))
warnings()
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.
Duncan Murdoch
______________________________________________
R-help@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.