### Function in R overwrites all values instead of current row, why?

I have the following function: SingleCos = function(x) { Cosfit = cosinor.lm(HR ~ time(Hour), period = 24, data = x) Cos3 = t(Cosfit$coefficients[1:3]) if (length(Cosfit$fit$fitted.values) < 4 & length(Cosfit$fit$model[, 1]) >4) { RhythmTest = cosinor.detect(Cosfit) RhythmPercent = cosinor.PR(Cosfit) CosOut = cbind(Cos3, RhythmTest, RhythmPercent) } else { RhythmTest = NA RhythmPercent = NA CosOut = cbind(Cos3,…

Details