hello given my reproducible example
#--- date<-seq(ISOdate(2017,1, 1, 0), by="hour", length.out = 48) v1<-1:48 df<-data.frame(date,v1) #-- I need to calculate the average of variable v1 at specific hour "endpoints" of the day: i.e. at hours 6.00 and 22.00 respectively the desired result is date v1 01/01/17 22:00 15.5 02/01/17 06:00 27.5 02/01/17 22:00 39.5 at hour 06:00 of each day the average is calculated by considering the 8 previous records (hours from 23:00 to 6:00) at hour 22:00 of each day the average is calculated by considering the 16 previous records (hours from 7:00 to 22:00) any hint please? I've been trying with some functions within the "xts" package but withouth much result... thanks for the help [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.