I am interested in calculating average values ββfor certain time periods in a time series data set.
For such time series:
dtm=as.POSIXct("2007-03-27 05:00", tz="GMT")+3600*(1:240) Count<-c(1:240) DF<-data.frame(dtm,Count)
In the past, I had to calculate daily averages using
DF$Day<-cut(DF$dtm,breaks="day") Day_Avg<-aggregate(DF$Count~Day,DF,mean)
But now I'm trying to shorten the day at certain periods of time, and I'm not sure how to set my βbreaksβ.
Unlike the average daily value from 0: 00: 24: 00, how, for example, can I get noon at noon?
Or more imagination, how could I set up noon at noon, excluding night times from 7pm to 6am (or vice versa, including only 6 AM-7PM daylight).
source share