title: How to calculate 8-days accumulated rainfall on a daily time series, using R?
body: <p>I am trying to calculate a 8-days accumulated rainfall, with this code, but it seems to not work well.</p>
  
  <p>chuva$Precipitacao it is my vector of daily rainfall, of length 5601.</p>
  
  <pre><code> rain&lt;-chuva$Precipitacao 
  j=1
  rain8&lt;-vector()
  for (i in 1:800){
     rain8&lt;-rbind(rain8, (rain[j]+rain[j+1]+rain[j+2]+rain[j+3]+
                       rain[j+4]+rain[j+5]+rain[j+6]+rain[j+7]));
    j=i+7
  }
  </code></pre>