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

Laravel query builder. Column if not null = 1 else = 0 in select method

I using Laravel and its \Illuminate\Database\Eloquent\Builder. I would like to select all columns from “table_1” a have custom column “is_table_2_present” which value will be 1 or 0 depending if(table_1_id != null). So I would like to do something like that. $queryBuilder->leftJoin(“table_2″….) $queryBuilder->select([ “table_1.*”, “is_table_2_present” = (table_2_id != null) ? 1 : 0, ]); I was…

Details