Is there a way to force the function to pass a value (e.g. 0) instead of failing and passing an error message to the screen?
The reason for asking is that I try to include an lme function(nlme) in an aggregate (stats) of a table but the lme function sends an error message in certain cases and the aggregate call fails.
example of the error message and the situation that cause it.
ID= c("3", "15", "24", "25", "26", "28", "29", "30")
value= c(0, 0, 0, 0, 0, 0, 0, 0)
fit = lme(value ~ 1, random = ~ 1 | ID)
Error in chol.default((value + t(value))/2) :
the leading minor of order 1 is not positive definite
Thanks!
?tryand/or?tryCatchare your friends (they may even be documented on the same page).I usually use an idiom like
(
inherits()is more general thanif class()==...becauseclass()can return a vector of characters with length > 1 …)