[R] tryCatch

Redding, Matthew Matthew.Redding at dpi.qld.gov.au
Mon Sep 1 01:45:51 CEST 2008


Hi All R-Gurus, 

I am trying to debug a program, and I think tryCatch will help. The functions involved 
process through so many times before I encounter the error, things are a bit slow to 
use debug and browser().

I've read the help file and postings on conditions, and am still having trouble.

While running my program I am getting a NAN from a called function, and I want to know the 
input parameters that generate this, so I have included the following in the code of the main
function (calling function):

tryCatch(delM > S, exception=function(e)print(list(S=S, Si=Si, D=D, theta=S/N, incr=del.t)), finally=print("finally"))

This is actually part of an "if" statement, where delM > S is the condition.
Now if delM is an NAN an error results.  

Now the above tryCatch does not work in the way I wish it.  What sort of condition does this little expression throw when it encounters delM=NAN? is it an exception? What is wrong with the above handler etc?

Kind regards, 

Matt Redding

********************************DISCLAIMER****************************
The information contained in the above e-mail message or messages 
(which includes any attachments) is confidential and may be legally 
privileged.  It is intended only for the use of the person or entity 
to which it is addressed.  If you are not the addressee any form of 
disclosure, copying, modification, distribution or any action taken 
or omitted in reliance on the information is unauthorised.  Opinions 
contained in the message(s) do not necessarily reflect the opinions 
of the Queensland Government and its authorities.  If you received 
this communication in error, please notify the sender immediately and 
delete it from your computer system network.


More information about the R-help mailing list