#Create a data.frame with a normally distributed variable at
#a 15 minute sampling rate.
TS <- seq(as.POSIXct("2000-01-01 00:00:00",
tz = "Europe/London"), as.POSIXct("2001-01-01 00:00:00", tz = "Europe/London"), by = 60*15)
TS <- data.frame(DateTime = TS, Var = rnorm(length(TS), 10, 2))
#use the function to aggregate to an hourly sampling rate, taking the maximum of each hour
Hourly <- AggDayHour(TS, func = max, Freq = "Hour")
#now aggregate with the mean at a daily scale
Daily <- AggDayHour(TS, func = mean, Freq = "Day")
#now aggregate with the sum at a 48 hour scale
Hr48 <- AggDayHour(TS, func = sum, Freq = 48)
#now aggregate with the sum at a 6 hour scale
Hr6 <- AggDayHour(TS, func = sum, Freq = 6)
Run the code above in your browser using DataLab