Re: [R] Parameterising apply To Compute Rolling Average of Columns in a matrix

2010-11-27 Thread Paolo Rossi
Awesome - thanks! Paolo On 17 November 2010 19:44, Ray Brownrigg ray.brownr...@ecs.vuw.ac.nzwrote: On Thu, 18 Nov 2010, Paolo Rossi wrote: I sent a post to find a clever way to compute a Rolling Average of columns in a matrix and I was given the solution below which I am very pleased

Re: [R] Parameterising apply To Compute Rolling Average of Columns in a matrix

2010-11-27 Thread Gabor Grothendieck
On Wed, Nov 17, 2010 at 2:27 PM, Paolo Rossi statmailingli...@googlemail.com wrote: I sent a post to find a clever way to compute a Rolling Average of columns in a matrix  and I was given the solution below which I am very pleased with. There is a zoo function that does this. The following

[R] Parameterising apply To Compute Rolling Average of Columns in a matrix

2010-11-17 Thread Paolo Rossi
I sent a post to find a clever way to compute a Rolling Average of columns in a matrix and I was given the solution below which I am very pleased with. RollingAverage - function(x, RollingObs) { cx - cumsum(x); N - length(x); Temp - (cx[RollingObs:N] - c(0, cx[1:(N-RollingObs)]))/RollingObs

Re: [R] Parameterising apply To Compute Rolling Average of Columns in a matrix

2010-11-17 Thread Henrique Dallazuanna
You've tried? apply(a, 2, RollingAverage, 7) On Wed, Nov 17, 2010 at 5:27 PM, Paolo Rossi statmailingli...@googlemail.com wrote: I sent a post to find a clever way to compute a Rolling Average of columns in a matrix and I was given the solution below which I am very pleased with.

Re: [R] Parameterising apply To Compute Rolling Average of Columns in a matrix

2010-11-17 Thread Ray Brownrigg
On Thu, 18 Nov 2010, Paolo Rossi wrote: I sent a post to find a clever way to compute a Rolling Average of columns in a matrix and I was given the solution below which I am very pleased with. RollingAverage - function(x, RollingObs) { cx - cumsum(x); N - length(x); Temp -