[R] Error trapping in R

Robert Knight bobby@kn|ght @end|ng |rom gm@||@com
Wed Feb 27 22:39:46 CET 2019


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.bernard using 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 using 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]]



More information about the R-help mailing list