Skip to content
Prev 205141 / 398506 Next

Help with tryCatch

Dr Sorkin;

You are a smart person. Why are you unable to create a working example  
that would allow testing of the code structure?
On Jan 1, 2010, at 10:27 PM, John Sorkin wrote:

            
# a simple dataset
# and a simple model would be more appropriate
# Try this untested (for lack of a working example) code:

# Do this 10 times
while (n<10) {
  resulttry<-try(testone(),final=n<-n+1)

# Do the function ran without an error
  if (class(resulttry) == "summary.glm" ){  #test for something that  
will distinguish
#the error (of type=="list") from a valid fit (also of type == "list")
  coeffs[n,1] <- result$coefficients[2,1]
  coeffs[n,2] <- result$coefficients[3,1]
  coeffs[n,3] <-  -(coeffs[n,1])/(2*coeffs[n,2])
  print(n)
  print(coeffs)} else {   }

}