I have a dataframe in R, contain 3000 rows and 2 columns (temp, flag), I am trying to calculate "meantemp" as the third column for every 6 rows if the correspondi