[R] Using try()

Nathaniel B. Derby nderby at u.washington.edu
Thu Sep 30 16:20:17 CEST 2004

Hello R people,

I am need some help using the try() function.  Currently I am running a loop which uses arima() for some values of p and q, which sometimes crashes.  When it crashes, I want the program to just ignore it and move on to the next values to loop through.  I currently have this, looping through a range of values for p and q:

lo = try( arima1 <- arima( y, order=c( p, 0, q ) )
if( !inherits( lo, "try-error" ) ){
      ... code here ...

This works perfectly for my purposes, with one exception:  Everytime the program invokes try(), I have to press Esc in the R console for the program to continue.  How can I avoid this (so that I don't have to keep pushing Esc).

I tried reading the help file for tryCatch(), which showed a wide range of options to try (no pun intended), but this confused me.



More information about the R-help mailing list