Re: [R] array question

2010-02-17 Thread Dennis Murphy
Hi: Alternatively, you could use rollmean in the zoo package: library(zoo) x <- c(2, 4, 5, 5, 6, 4, 5, 2, 1) rollmean(x, 4) [1] 4.00 5.00 5.00 5.00 4.25 3.00 which avoids the NAs that get produced from filter: filter(x, rep(1/4, 4)) Time Series: Start = 1 End = 9 Frequency = 1 [1] NA 4.00 5.00

Re: [R] array question

2010-02-17 Thread Benilton Carvalho
you mean something along the lines of filter(x, rep(1/4, 4)) (which you can combine with na.omit) ? On Wed, Feb 17, 2010 at 5:18 PM, Mohsen Jafarikia wrote: > Hello All: > > If I do have: > > x = (2, 4, 5, 5, 6, 4, 5, 2, 1) > y = (9, 11.5, 12.5, 13, 14, 19, 20, 21, 22) > > I wanted to find a s