Hello, I'm trying to fit some points with a 8-degrees polynom (result of lm is stored in pfit). In most of the case, it is ok but for some others, some coefficients are "NA". I don't really understand the meaning of these "NA".
And the problem is that I can't perform a derivation (pderiv<-as.function((deriv(polynomial(pfit$coefficients))))) on pfit due to the presence of these "NA". I tried the functions na.omit and na.exclude but "NA" are still there. I tried to replace manually "NA" by 0. The fit seems ok and then I can derive the polynom. But can I do this and, if yes, how can I detect and automatically replace these "NA" ? To conclude, I must say that I read some posts on NA but I must confess that it is still not clear to me (maybe because I'm french and R-newbie ...) Thanks in advance for your help, Ptit Bleu. pfit Call: lm(formula = pfitmax ~ poly(vfitmax, 8, raw = T)) Coefficients: (Intercept) poly(vfitmax, 8, raw = T)1 poly(vfitmax, 8, raw = T)2 poly(vfitmax, 8, raw = T)3 poly(vfitmax, 8, raw = T)4 -2.790e+04 6.276e+03 -5.645e+02 2.591e+01 -6.241e-01 poly(vfitmax, 8, raw = T)5 poly(vfitmax, 8, raw = T)6 poly(vfitmax, 8, raw = T)7 poly(vfitmax, 8, raw = T)8 6.681e-03 NA -3.942e-07 NA >pderiv<-as.function((deriv(polynomial(pfit$coefficients)))) Erreur dans while ((la <- length(a)) > 1 && a[la] == 0) a <- a[-la] : valeur manquante là où TRUE / FALSE est requis -- View this message in context: http://www.nabble.com/Can-I-replace-NA-by-0-%28if-yes%2C-how%29---tf4765597.html#a13629975 Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.