I have a question that might be trivial for most of you guys. I tried a lot, did not come to a solution, so I would be glad if someone could give me a hint. The starting point is the weekly xts series.
Month Week Value Goal
Dec 2011 W50 aa
Dec 2011 W51 b mean (a, b)
Dec 2011 W52 c mean (a, b, c)
Dec 2011 W53 d mean (a, b, c, d)
Jan 2012 W01 ee
Jan 2012 W02 f mean (e, f)
Jan 2012 W03 g mean (e, f, g)
Jan 2012 W04 h mean (e, f, g, h)
Feb 2012 W05 ii
Feb 2012 W06 j mean (i, j)
Please excuse the Excel notation, but I think itβs pretty clear what I want to do: I want to calculate the left-side moving average for the βValueβ column, but only for the corresponding month, since it is displayed in the Target column. I experimented with apply.monthly () and period.apply () . But I did not understand what I want. Can any of you give me a hint how to solve the problem? Just a hint which function should I use will be enough!
Many thanks!
Yours faithfully,
Andreas
source share