[R] General "moving" functions
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Thu May 2 11:43:38 CEST 2002
filter() in package ts.
On Thu, 2 May 2002, Neil Osborne wrote:
> General "moving" function.
> I'm a relatively new comer to R, and I've only just started writing my own R
> functions. However, I need some help for something which I'm sure is quite
> straight forward.
> I want to write a function that will allow me to calculate "moving results"
> for a given vector. Ideally, the function will be of the form
> foo<-function(vector1, funcname, lag)
> for example, if I use arguments :
> funcname = mean
> lag = 10
> Then foo will return a vector of 10 day moving average
> Many Thanks
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help