0

I am running a very long simulation, and about 1 in every 20 iterations a model fails to converge which trashes the whole thing.

I know I can use try() with the offending model to skip past it in the event of an error, but I was wondering if this could be extended into a conditional? By which I mean if an error did occur, it would execute another short script instead of the code that caused the error. Kind of like an if statement for errors.

Thank you all.

Roger Hill
  • 13
  • 2
  • [tryCatch](https://stackoverflow.com/questions/12193779/how-to-write-trycatch-in-r)? Not sure if R has try-except but maybe you can use an if statement based on what you expect to go wrong. – NelsonGon Feb 10 '21 at 13:14

1 Answers1

0

You can use tryCatch function, a tutorial can be found here: https://www.r-bloggers.com/2012/10/error-handling-in-r/

Tibo
  • 68
  • 1
  • 7