Re: [R] running mean in blocks

2011-07-11 Thread Mateo Sanchez
Hi all, Thanks for the suggestions. What I ended up using was x=aggregate(dat,by=list(dat$DOY,dat$Hour),mean) where is my matrix and DOY is day of year. This gives me hourly means for each day (apologies for not being more specific with my question). This works for now but I'll probably want to

Re: [R] running mean in blocks

2011-07-11 Thread David Winsemius
On Jul 11, 2011, at 9:23 AM, Joshua Wiley wrote: Hi, Take a look at package "zoo", perhaps something like: require(zoo) x <- rnorm(1) # hypothetical data m <- rollapply(zoo(x), width = 100, FUN = mean, by = 100) Definitely a better answer, but if all your rolling averages were of the f

Re: [R] running mean in blocks

2011-07-11 Thread peter dalgaard
On Jul 11, 2011, at 11:23 , M. B wrote: > Hello, > I am running R on Linux and have a column of data 1 points long. I would > like to take a moving average of say 100 points at a time, so I end up with > one column of 100 points. What is the simplest way of doing this? I would > like to be a

Re: [R] running mean in blocks

2011-07-11 Thread Joshua Wiley
Hi, Take a look at package "zoo", perhaps something like: require(zoo) x <- rnorm(1) # hypothetical data m <- rollapply(zoo(x), width = 100, FUN = mean, by = 100) Another (bit more of a hack) option would be: ## convert vector to matrix byrows with 100 columns per row ## (where 100 is the n

[R] running mean in blocks

2011-07-11 Thread M. B
Hello, I am running R on Linux and have a column of data 1 points long. I would like to take a moving average of say 100 points at a time, so I end up with one column of 100 points. What is the simplest way of doing this? I would like to be able to adjust the width of the averaging blocks. Th