Nash wrote:
Uwe Ligges wrote:
Please read the question more carefully, the sin() example was used as a method that does not give an error but works as expected (just with the warning), but the question is how not to break the loop,
 and so my answer was "see ?try".

So,
Do you have any solution about his problem ?


Yes he does: Use try().

This may not be very specific, but neither was the original question. The poster didn't give an example that we could fix, only the sin() example that he wanted his own code to work _like_.

So to answer the question with working code, one first needs to invent a broken example. Perhaps something like

for(i in 2:-2) {
   x <- try(chol(as.matrix(i)))
   if(inherits(x,"try-error")) x <- NaN
   print(x)
}


--
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalga...@biostat.ku.dk)              FAX: (+45) 35327907

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to