Function to calculate rollmean