to.period
does not perform an aggregation, it just converts your time series to the desired frequency. To do aggregation, use zoo.aggregate
. There's also a handy function align.time
in xts
package, that takes care of the by
argument:
as.xts(aggregate(x, align.time(index(x), 15*60)))
[,1]
2007-01-03 09:00:00 3
2007-01-03 09:15:00 3
2007-01-03 09:30:00 9
2007-01-03 09:45:00 6
2007-01-03 10:00:00 15
2007-01-03 10:15:00 9
2007-01-03 10:30:00 32
2007-01-03 10:45:00 34
2007-01-03 11:00:00 81
2007-01-03 11:15:00 78
2007-01-03 11:30:00 10
2007-01-03 11:45:00 54
2007-01-03 12:00:00 55
2007-01-03 12:15:00 110
2007-01-03 12:30:00 0
2007-01-03 12:45:00 0
2007-01-03 13:00:00 0
2007-01-03 13:15:00 67
2007-01-03 13:30:00 78
2007-01-03 13:45:00 109
2007-01-03 14:00:00 10