[R] tryCatch - return from function to main script
Anne-Marie Ternes
amternes at gmail.com
Tue Jul 15 12:59:37 CEST 2008
Dear helpers,
I've got a main script, which calls 4 times a function on 4 different
datasets respectively. This function runs "nls" and is located in
another R script which is sourced into my main script.
What I would like to have is this:
If, e.g. in the 3rd call of the function, nls fails, because it can't
converge, I would like it to return an error (value or message), and
continue with the 4th call in my main script.
I've tried "try", but it always completely stops execution. I've also
played around with "tryCatch", but to be honest, the help page is
quite cryptic to me. I'm sure "tryCatch" has a way of being told to
"ok, stop this, and continue with the main script".
As I'm quite in a hurry (need to finish this before leaving tomorrow),
I'd be glad if you could give me a very practical example - I promise
to look deeper into the details of exception handling in R when I'm
back.
Thanks a lot!!
Anne-Marie
More information about the R-help
mailing list