[R] Using try()

Nathaniel B. Derby nderby at u.washington.edu
Thu Sep 30 19:53:32 CEST 2004


Thanks, Spencer!

As a neophyte to the R mailing lists, I shall follow the guidelines of the posting guide.  As for my specific question (which concerns R 1.9.1 on WinXP, using WinEdt as my editor), I solved it myself in the following manner:


options( show.error.messages = FALSE, error=expression( NULL ) )
   # supresses the error messages and stops
for( ... values of p and q ... ){
      lo = try( arima1 <- arima( y, order=c( p, 0, q ) )
      if( !inherits( lo, "try-error" ) ){
           ... code here ...
           }
      }
options( show.error.messages = TRUE, error=NULL )
   # brings back the error messages and stops


Following a tip from ?stop, it's quite adviseable to bring back the stops and error messages after the loop!


Thanks,

Nate



On Thu, 30 Sep 2004, Spencer Graves wrote:

>     Are you using ESS?  If yes, can you try to code in RGui, without Emacs or 
> XEmacs?      If that fails, "PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html", and tell us which version of R, 
> what operating system, etc.      hope this helps.      spencer graves
>




More information about the R-help mailing list