[R] aggregating specific parts in zoo index column to perform sliding average
knavero
knavero at gmail.com
Tue Feb 28 04:17:00 CET 2012
Here's my code:
http://pastebin.com/0yRxEVtm
The important parts are uncommented and should be easy to find using the
link above. For the following line of code, I plan on looking for a way to
offset it up 7 rows so that the 15 minute timestamp would be considered the
"median" of the subset being averaged to find the mean:
avgCool = aggregate(intCool, trunc(time(intCool), times("00:15:00")), mean)
Currently the issue is that, with the truncate function, it "truncates" but
really rounds down the time series values to the 15 minute time stamp
earlier in the series. For example, let's say we have one minute intervals
0:00, 0:01, 0:02,....,0:37. It takes 0:00 - 0:14 and replaces that with
0:00. Then it sees 0:15, and changes values from 0:15 - 0:29 to 0:15. In
effect, aggregating the values and creating subsets.
What I want to do here is change 0:00 - 0:07 to 0:00, change 0:08 - 0:22 to
0:15, and change 0:23 - 0:37 to 0:30 in which 0:15 and 0:30 are the medians
of each subset. Anyway, I hope that makes sense. Any ideas on which function
will make this an easy job? Much thanks in advance.
--
View this message in context: http://r.789695.n4.nabble.com/aggregating-specific-parts-in-zoo-index-column-to-perform-sliding-average-tp4426798p4426798.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list