Hi, You may try ?rollmean from library(zoo) ?SMA from library(TTR) dat1 <- structure(... library(zoo) res1 <- rollmean(dat1[-c(1:5),2],8) library(TTR) res2 <- SMA(dat1[-c(1:5),2],8) ?all.equal(res1,res2[!is.na(res2)]) #[1] TRUE A.K. Hi, How can I calculate running 8-hour averages of temperature values that start at specific date and time? In the example data set shown below I want to start the calculation on May 31, at 5pm (row 6). Reproducible data is provided. Thanks structure(list(date = structure(c(644148000, 644151600, 644155200, 644158800, 644162400, 644166000, 644169600, 644173200, 644176800, 644180400, 644184000, 644187600, 644191200, 644194800, 644198400, 644202000, 644205600, 644209200, 644212800, 644216400, 644220000, 644223600, 644227200, 644230800, 644234400, 644238000, 644241600, 644245200, 644248800, 644252400, 644256000), class = c("POSIXct", "POSIXt"), tzone = ""), temp = c(17.7, 18.3, 18.9, 19.7, 19.5, 19, 18.8, 18, 16.3, 15.1, 13.9, 12.7, 11.9, 10.6, 10, 8.7, 7.89999, 8.09999, 9.29999, 12.4, 14.5, 15.9, 17.4, 18.6, 18.3, 18.4, 18.5, 20.4, 19.7, 18.9, 18.1)), .Names = c("date", "temp"), row.names = 3613:3643, class = "data.frame")