> 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?
If I've read this correctly, the problem is not so much about tryCatch, as
it is about testing for NaNs. If delM is NaN, then your condition is NaN
> S, which is NA. if(NA) then throws an error satating that there is a
missing value wehre TRUE/FALSE is needed.
You need to test for NaN in your condition using is.nan(),
e.g. replace
delM > S
with
is.nan(delM) || delM > S
Regards,
Richie.
Mathematical Sciences Unit
HSL
------------------------------------------------------------------------
ATTENTION:
This message contains privileged and confidential inform...{{dropped:20}}