I want to calculate 1-min and 5-min mean values from a dataset with 1-min values.
The dataset looks like this:
time BC
1 10:40:01 2217
2 10:40:02 5776
3 10:40:03 2111
4 10:40:04 1407
5 10:40:05 2056
.
.
.
n 11:30:58 6044
I found a post where someone suggested the zoo(aggregate)
function for this.
I tried it like this:
time<-as.character(time)
BC<-as.numeric(BC)
BC_mean<-aggregate(BC, trunc(time, "00:01:00"), mean)
However, it doesn't work. I am not quite sure if I understand the aggregate function correctly and the definitions I found online are confusing me even more. Can someone help me?