That makes sense. Thanks Gabor! Josh
On Wed, Jul 21, 2010 at 4:07 PM, Gabor Grothendieck <ggrothendi...@gmail.com> wrote: > On Wed, Jul 21, 2010 at 6:59 PM, Joshua Wiley <jwiley.ps...@gmail.com> wrote: >> Hello, >> >> I am using rollapply() from package zoo to use a function on unique >> windows from a dataset. Because my dataset is not a multiple of my >> window width, it matters which end I start at. Here is a simple >> example, the result I want is 7.5 (i.e., start at the highest level of >> my ordering variable). I thought that the argument ascending = FALSE >> would do it, but it does not seem to have an effect. It seems like I >> must be missing something simple. >> >> #Library and sample data >> library(zoo) >> mydata <- zoo(x = 6:8, order.by = 1:3) >> >> rollapply(data = mydata, width = 2, by = 2, >> FUN = mean, ascending = TRUE, align = "left") >> >> #This gives the same results >> rollapply(data = mydata, width = 2, by = 2, >> FUN = mean, ascending = FALSE, align = "left") >> >> > > ascending only specifies the order to pass each set of points but does > not change the sets themselves. Try this: > > >> rollapply(data = mydata[-1], width = 2, by = 2, FUN = mean) > 2 > 7.5 > -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.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.