[R] How to calculate moving average without using filter()?
gunter.berton at gene.com
Mon Feb 17 20:05:22 CET 2014
There are a zillion answers to this, because your question is really:
How do I smooth a time series? So you can search on appropriate
My answer is: don't use moving averages -- that's pathetically
ancient. ?loess is one among the zillions of alternatives you might
consider. Post on CV (stats.stackexchange.com) for other statistical
alternatives for time series smoothing.
Also, the "understanding" you expressed above is flawed. apply-type
constructs **are** (R-level) loops. So have you done your homework by
reading An Intro to R
(http://cran.r-project.org/doc/manuals/R-intro.pdf) or other web
tutorials? If not, please do so before posting here further.
Genentech Nonclinical Biostatistics
"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
H. Gilbert Welch
On Mon, Feb 17, 2014 at 10:45 AM, C W <tmrsg11 at gmail.com> wrote:
> Hi list,
> How do I calculate a moving average without using filter(). filter() does
> not seem to give weighted averages.
> I am looking into apply(), tapply,... But nothing "moves".
> For example,
> I understand the point of apply is to avoid loops, how should I incorporate
> this idea into using an apply()?
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help