Some use try blocks, like found in other languages.  Put the code you want to 
try inside the block.

https://www.robertknight.io/blog/try-blocks-in-r-for-error-handling/ contains a 
quick example.  The example doesn’t raise exceptions or anything, it just 
contains it for you so the script keeps going.  I like handling errors with if 
statements inside of try blocks.

Robert



> On Feb 27, 2019, at 2:55 PM, Bernard Comcast <mcgarvey.bern...@comcast.net> 
> wrote:
> 
> What is the recommended way to trap errors in R? My main need is to be able 
> to trap an error and then skip a section of code if an error has occurred. In 
> VB for Excel I used the “On Error goto  .....” construct to do this.
> 
> Bernard
> Sent from my iPhone so please excuse the spelling!"
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to