In my r script, I do perform an nls to get a fit value:
fit <- nls(...)
and then after that, I test if the nls succeeded by doing this:
if(is.na(fit)) {
print("succeeded")
}
but I get warnings:
the condition has length > 1 and only the first element will be used
am I doing this wrong? if so, what should I do? if not, how do I remove the warning? thanks!
nlsinduces an error if the fitting failed. So,is.nullaftertry(nls(...))is the correct way.here is a piece of code I used when using
nlsfit for uncertain data: