[R] Moving average

From: Bernard L. Dillard <bld_at_math.umd.edu>
Date: Thu 16 Jun 2005 - 22:04:18 EST

Good morning all!

I am attempting to superimpose a moving-average smoother onto a graph of daily plots. These plots (in table[,2] below) span about 350 days and looks very noisy. I'd like for this smoother to plot the average of each group of 7 consecutive days (weekly) and show a line which joins these series of averages. Given the definition of MA, the first and last points will generally overlap in the average calculation.

It's probably a one-liner, but I still am having some problems with the syntax. The only part I have correct is the "lines" statement to ensure it overlays my original graph.

Here's the code I have thus far:

y <- table[,2]
lines( ......) {moving average code here to be placed here}

Any time series gurus out there? Be gentle. I'm an R beginner.



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jun 16 22:11:26 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:43 EST