title: R: how to average every 7th row
body: <p>I want to take the average of each column (except the date) after every seven rows. I tried the approach below, but I was getting incorrect values. This method also seems really long. Is there a way to shorten it?</p>
  <pre><code>bankamerica = read.csv('https://raw.githubusercontent.com/bandcar/Examples/main/bankamerica.csv')
  
  library(tidyverse)
  GroupLabels &lt;- 0:(nrow(bankamerica) - 1)%/% 7
  bankamerica$Group &lt;- GroupLabels
  
  Avgs &lt;- bankamerica %&gt;% 
    group_by(bankamerica$Group) %&gt;% 
    summarize(Avg = mean(bankamerica$tr))
  
  </code></pre>
  <p>EDITED: Just realized this code provides the incorrect values</p>