Re: [Rd] Handling warning messages

From: Paul Roebuck <roebuck_at_odin.mdacc.tmc.edu>
Date: Fri 12 Aug 2005 - 13:58:05 GMT

On Fri, 12 Aug 2005, Nikhil Shah wrote:

> I have query regarding R & Rserve. In Rserve, there is a
> way to capture Errors by RSrvException class, but is there
> any way to capture warning messages?

options(warn = 2) work for you?

> I have found that there is "warnings()" command in R, which
> lists the last warning message, but I am not able to get
> the warning message in java program by executing the
> following line:
>
> REXP rx = null;
> // will generate warning message
> rx = connection.eval("x<-sqrt(-9)");
> // this displays null instead of warning message
> connection.eval("warnings()").asString();
>
> Please reply me correct way, if any, to display warning
> message.

Probably need some mods to your Java source to handle this but something like the following would enable you to receive notice of errors/warnings. But it's hard to answer this question in terms of context since I have no idea what you're doing.

tryCatch(x<-sqrt(9),

         warning = function(w) w,
         error = function(e) e)

And Java programming questions are inappropriate for the R-help mailing list.



SIGSIG -- signature too long (core dumped)

R-devel@r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat Aug 13 00:34:23 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:16 GMT