[R] Suppressing error messages in a for loop

hgreatrex h.greatrex at rdg.ac.uk
Thu Oct 16 22:46:17 CEST 2008


Is there any way that I can supress error messages so that they don't stop
for loops running?

I'm using the gstat package and have created a variogram model for the
double exponential model:

    "dexp <- vgm( .5, "Exp", 10,.1, add.to = vgm(.5, "Exp", 100))" 

and fitted it using
    "dexp.fit <- fit.variogram(temp2, dexp, fit.method=6, debug.level=0)"

Occasionally I get the following error message and the model doesn't fit

    "Error in if (direct[direct$id == id, "is.direct"] && any(model$psill < 
     missing value where TRUE/FALSE needed"

I don't mind that the model doesn't converge, however the error message
stops the for loop I'm running at the time (and so stops my code!).  Is
there any way that I can suppress the error message?

Sorry if this is a really simple question, I'm still new to r programming!
Best wishes
Helen Greatrex

View this message in context: http://www.nabble.com/Suppressing-error-messages-in-a-for-loop-tp20016800p20016800.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list