I believe the lag() function can be used to rig this up. Something like sma.365 <- SMA(lag(data, 12), n=120) # Untested, but seems right
Michael On Thu, Oct 13, 2011 at 6:31 AM, Laura <janna...@web.de> wrote: > Hello, > > I used the TTR package in R to calculate moving averages. I have a monthly > time series and I would like to calculate the moving average over 10 years > with an offset of 1 year. > It should be something like sma.365 <- SMA(data, n=120) > > Does anyone know how to include in offset? > > > Thanks a lot for your help. > > Best regards! > > -- > View this message in context: > http://r.789695.n4.nabble.com/moving-average-TTR-tp3901080p3901080.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.