Skip to content

Rolling through fixed-length time windows

4 messages · Matthew Clegg, Gabor Grothendieck

#
On Fri, Nov 4, 2011 at 9:09 AM, Matthew Clegg <matthewcleggphd at gmail.com> wrote:
Here is a one liner (two if you count making the result into a zoo object):
1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 1  3  6  9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 72
3 days later
#
On Mon, Nov 7, 2011 at 8:50 AM, Matthew Clegg <matthewcleggphd at gmail.com> wrote:
The rollapply slowdown was reported and fixed in the development
version of zoo already. It only affected recent versions of zoo since
rollapply was rewritten to add certain features. See:

http://r.789695.n4.nabble.com/zoo-performance-regression-noticed-1-6-5-is-faster-tt3990753.html#a3993387

Certainly zoo indexing can be expensive and in those cases that do
involve indexing in an inner loop, replacing zoo object z with zc <-
coredata(z) and tt <- time(z) speeds things up.  Typically that covers
fewer computations than you might think because most R code takes the
whole object approach.