Re: [R] "fill in" values between rollapply

2010-04-10 Thread Gabor Grothendieck
Here are two solutions. Assuming x is a zoo object both return zoo objects: 1. rollapply with na.pad and na.locf: r <- rollapply(x, 5, mean, by = 5, align = "left", na.pad = TRUE) na.locf(r) 2. or try this which does not use rollapply at all but assumes x is 1 dimensional: n <- length(x)

Re: [R] "fill in" values between rollapply

2010-04-10 Thread Brad Patrick Schneid
Dennis: I had never used the rep() function and that works out great, thank you. Brad -- View this message in context: http://n4.nabble.com/fill-in-values-between-rollapply-tp1816885p1835513.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] "fill in" values between rollapply

2010-04-09 Thread Brad Patrick Schneid
Dennis: I will check this out tonight and let you know, it seems promising. Either way, thanks for the suggestion. Brad On Fri, Apr 9, 2010 at 12:03 PM, Dennis Murphy [via R] < ml-node+1819642-2015310724-118...@n4.nabble.com > wrote: > Hi: > > Not exactly elegant, but here's one approach: > lib

Re: [R] "fill in" values between rollapply

2010-04-09 Thread Dennis Murphy
Hi: Not exactly elegant, but here's one approach: library(zoo) x <- zoo( rpois(100, 40) ) w <- rollapply(x, 5, mean, by = 5, align = c('left')) x2 <- rep(w, each = 5) Does that work? HTH, Dennis On Fri, Apr 9, 2010 at 12:32 AM, Brad Patrick Schneid wrote: > > Hi, > Sorry ahead of time for not

Re: [R] "fill in" values between rollapply

2010-04-09 Thread Dieter Menne
Brad Patrick Schneid wrote: > > If this doesn't make sense, I will clarify and provide data for an > example. > Which is always a good idea. Dieter -- View this message in context: http://n4.nabble.com/fill-in-values-between-rollapply-tp1816885p1819092.html Sent from the R help mailing l