I would like to add boundary conditions to this for loop:
for (i in seq_along(x)) { x[i] = ifelse(sum(x[(i-1):i]) > 0, 0, sum(x[(i-1):i]))}
The condition is: If the sum is below a fixed limit, the printed value will be the limit value.
I tried this but it doesn't seem to work:
for (i in seq_along(x)) { x[i] = ifelse(sum(x[(i-1):i]) > 0 ,0, sum(x[(i-1):i]))
if (sum(x[(i-1):i]) < min(x)*0.5) {
min(x)*0.5
}
}
Thanks for help!
Aucun commentaire:
Enregistrer un commentaire