[R] block averaging data frames

2011-12-19 Thread Mathew Brown
Hi there, This seems like it should be simple. I have a data frame of climate data sampled every 10 min. I want to average the entire data frame into 30 min values (i.e., one value for each half hour). Functions like running.mean give me a moving average but I want to reduce the size of

Re: [R] block averaging data frames

2011-12-19 Thread jim holtman
Does this work for you: x - read.table(text = date time Voltage LwTempDownelling LwDownwelling LwDownwelling_min LwDownwelling_max LwTempUpwelling + 1 2011-11-01 00:00:00 2.73244717.30 30.0 14.0 39.5 17.83 + 2 2011-11-01 00:10:00 2.731534

Re: [R] block averaging data frames

2011-12-19 Thread Mathew Brown
Hmm, almost but my real data frame is much larger (128 columns). The problem is with this line newData - do.call(rbind, tapply(x[4:8], x$interval, colMeans)) when I do tapply(x[4:8], x$interval, colMeans) all works but when I do tapply(x[4:7], x$interval, colMeans) I get Error in

Re: [R] block averaging data frames

2011-12-19 Thread Mathew Brown
Almost except tapply(x[4:8], x$interval, colMeans) works but with a larger data frame I have problems, even tapply(x[4:7], x$interval, colMeans) gets the arguments must have the same length error. But they do! Any ideas? Thanks for your help Jim On 12/19/2011 2:00 PM, jim holtman wrote: