To calculate the rolling mean in R, we can use either the zoo or dplyr library. Here is an example using zoo:
main.r348 chars12 lines
The output will be:
main.r363 chars12 lines
Alternatively, we can use dplyr and zoo to accomplish the same task:
main.r380 chars14 lines
The output will be the same as before.
gistlibby LogSnag