Re: [R] Is it possible to coerce R to continue proceeding the next command in a loop after an error message ?

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Sun 17 Jul 2005 - 10:51:48 EST

Yimeng Lu wrote:
> Hello R-users,
>
> In a loop, if a function, such as "nls", gives an error, is it possible to
> coerce R to continue proceeding the next command with the same
> loop?
>

Yes, see the try() function. The basic usage is something like

value <- try( some calculation )
if (inherits(value, "try-error")) handle the error else handle a correct calculation

Duncan Murdoch



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sun Jul 17 10:55:18 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:46 EST