I think that the existing answers are not general enough, since they do not take into account that the time interval can be in several environments.
shift data.table.
library(data.table)
setDT(df)
. () :
df[, ave_val :=
Reduce('+',c(shift(value, 0:5L, type = "lag"),shift(value, 1:5L, type = "lead")))/11
]
:
mids <- seq(as.POSIXct("2010/1/1 00:00"), as.POSIXct("2010/1/5 00:00"), by = 60*60) + 30*60
:
setkey(df,DateTime)
df[J(mids)]