[Rd] Handling warning messages

2005-08-12 Thread Nikhil Shah
Hi,

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?

   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;
rx = connection.eval("x<-sqrt(-9)"); // will generate warning message
connection.eval("warnings()").asString(); // this displays null instead of
warning message

Please reply me correct way, if any, to display warning message.

Regards,
Nikhil Shah

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Handling warning messages

2005-08-12 Thread Paul Roebuck
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