I have two arrays out and res and c a number. I have this code :
for(i in 1:N) {
    out[i] <- c - sum(res[1:i]) / i 
}
Is is possible to simplify this code in a single line, something like this :
out = c - sum(res[1: ???] / i
I have two arrays out and res and c a number. I have this code :
for(i in 1:N) {
    out[i] <- c - sum(res[1:i]) / i 
}
Is is possible to simplify this code in a single line, something like this :
out = c - sum(res[1: ???] / i