[R] Histogram and moving average

Dieter Menne dieter.menne at menne-biomed.de
Tue Apr 14 15:02:16 CEST 2009


Vallat Morgan <morgan.vallat <at> epfl.ch> writes:

> I have a 'basic' issue and hope someone has a bit of code to solve it. I
> have two populations plotted as histograms on the same figure. Basically I
want to add the moving average
> (based on hist) for both populations on my graph. I'm also interested in the x
coordinate of the curves
> intersection. 

Moving averages are fine if you do not have future data (such as stock markets
or temperatures), but suboptimal for densities.

R has powerful methods for these: If you have MASS (the book, check ch. 5.6). Or
the examples in library/MASS/scripts/ch05.R

Dieter




More information about the R-help mailing list