From roebuck at odin.mdacc.tmc.edu  Fri Aug 12 15:58:05 2005
From: roebuck at odin.mdacc.tmc.edu (Paul Roebuck)
Date: Fri, 12 Aug 2005 08:58:05 -0500 (CDT)
Subject: [Rd] Handling warning messages
In-Reply-To: <004801c59f28$e1147650$7900a8c0@dca.com>
References: <004801c59f28$e1147650$7900a8c0@dca.com>
Message-ID: <Pine.OSF.4.58.0508120848130.268788@odin.mdacc.tmc.edu>

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)



[Rd] Handling warning messages
Paul Roebuck