Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

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

Duncan Murdoch

2005-07-16

Replies:

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@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
©2008 r-help.com - Jax Systems, LLC, U.S.A.