I am running a glm() function nested in for() function. The output of the glm is entered into a matrix. For some of the cycles there is a warning but i get all the warnings only at the end of all the cycles so i can not know which cycle was bad. I would like to get an indication if there is a warning after each glm calculation so i can tell the script not to enter this cycle result to the matrix. Any ideas how to do this? example:
m<-matrix(nc=1,nr=100)
for(i in 1:100){
fit<-glm(y~x+v1+v2+v3,data=data)
if("there is a warning???"){
m[i,1]<-NA
}
else{
m[i,1]<-fit$coefficients[2,1]
}
"reset warning???"
}
Thank you