How to caclulate moving average for proportional data using zoo package (rollmean)

36 Views Asked by At

I have the sample dataframe as below,

enter image description here

Where for each date the total 'value' score is 1 as the 'varible' is proportion. Now how can I calculate the zoo:rollmean for 'value' based on dates considering 'variable'?

In the end I need to make areaplot using all mean variable values according to date as below.

enter image description here

I have tried group_by(variable) but it did not give the desired output

Thank you! Wasim

0

There are 0 best solutions below