I would like to aggregate each two cell values by mean and continue with the same process down the column of the dataframe. To be more precise see the following dataframe extract:
X Y Z
1 FRI 200101010000 -6.72
2 FRI 200101010030 -6.30
3 FRI 200101010100 -6.26
4 FRI 200101010130 -5.82
5 FRI 200101010200 -5.64
6 FRI 200101010230 -5.29
7 FRI 200101010300 -5.82
8 FRI 200101010330 -5.83
9 FRI 200101010400 -5.83
10 FRI 200101010430 -6.04
11 FRI 200101010500 -5.80
12 FRI 200101010530 -6.09
I would like to calculate the mean of every Z by Y ending with 00 and 30, that means calculate mean of #row 1+2, #row 3+4, #row 5+6 and so on...see what I expect here:
X Y Z
1 FRI 200101010100 -6.51
2 FRI 200101010200 -6.04
3 FRI 200101010300 -5.47
...
Explanation: Y is time: YYYYMMDDhhmm and I would like to average measurements of 30min to measurements of 1h
Here's a possible
data.table
solutionOr per @akruns comment, using
aggregate
from base (though the output will need some additional tweeking probably)