Hi all, I have a function - let's call it "myfunction". This function is based on some random number generator. Now, once in a while the function will break/crash depending on the random number it generate inside the function.
To avoid the problem, what I intend to do is the following: 1. Catch the try-error using class. 2. Redo the function if it returns "try-error" 3. Otherwise keep the output of the function. I'm not sure how to create the above construct. The code I have below doesn't work: __BEGIN__ myfunction <- function(the_x) { # do something a = list(output1=val1, output2 = val2) a } out <- try(suppressWarnings(myfunction(x)),silent=T) if (class(out) == "try-error") { #this clause doesn't seem to "redo" out <- myfunction(X) } else { ll <- out$output1 } __END__ - Gundala Viswanath Jakarta - Indonesia ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.