[R] Error handling

Duncan Murdoch murdoch at stats.uwo.ca
Wed Sep 12 13:02:09 CEST 2007


On 12/09/2007 5:08 AM, Christian Schäfer wrote:
> Hi,
> 
> is there a possibility to catch an occurring error and do an appropriate 
> error handling? (like the "try-catch"-statement in other programming 
> languages)

You could use the tryCatch() function (or try(), a simplified wrapper).

Duncan Murdoch
> 
> For example:
> It's quite annoying to run a script for hours only to detect an abortion 
> of the script because of an "subscript out of bounds" error. In that 
> case I would like to react accordingly, i.e. by skipping the actual step 
> in the for-loop, or so.
> 
> Thanks,
> Chris
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list