Error handling
On 5/23/05, Carsten Steinhoff <carsten.steinhoff at gmx.de> wrote:
Hi, I have written an R-Procedure that automatically does a ML-Fit for some datasets to a few selected distributions. After any optimization the function writes the estimated parameters into a variable. My problem is now that sometimes the optimization failes and my program stops with an error message. What I want after a failed optimization is that there is written an error msg in the variable instead of stopping the program. For the ML-Fit I use the "fitdistr" algorithm.
See ?try ?tryCatch For example, using try: result <- try(myfun(...whatever...)) if(inherits(result, "try-error")) ...process the error...