Ronaldo Reis-Jr. wrote:
> Hi,
>
> I have the follow function:
>
> function() {
>
> ## Init of function
> ...
>
> for(i in test) {
> ...
>
> while(j <= test2) {
> ...
>
> }
> }
> }
>
> The problem is that sometimes, naturally, the while is not possible to be
> resolved, and so the program abort.
>
> In this case I need that program return to the init of function and run again.
Wrap the call to your function in try(), and if the result is a
try-error, try it again. E.g. if your function is named f, do something
like this:
repeat {
result <- try(f())
if (!inherits(result, "try-error")) break
}
Duncan Murdoch
>
> How I can make this? Abort the while, abort the for and run the function
> again?
>
> Thanks
> Ronaldo
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html