From this previous post: enter link description here
I would like to calculate two function based on condition length
. When lst
argument is <=4
one function else second function, I tried with:
lapply(lst, function (x) ifelse((sapply(lst,length)<=4)==T,scale,
(fit <- lm(x ~ poly(seq(1:length(x)), 5, raw=TRUE)))
(d <- resid(fit)-mean(resid(fit)))/sd(resid(fit))))
but there is an error:
Error in ifelse((sapply(lst, length) <= 4) == T, scale, (fit <- lm(x ~ :
unused argument (d <- resid(fit) - mean(resid(fit))/sd(resid(fit)))
How can I to calculate the fit and the z.score of the residuals in the same function when the length is more then 4?
Aucun commentaire:
Enregistrer un commentaire