Skip to content
Prev 205163 / 398506 Next

Question on Reduce + rollmean

Let me rephrase;

Given x as
[[1]]
   V1 V2 V3
[1,]  1  1  1
[2,]  2  2  2
[3,]  3  3  3

[[2]]
   V1 V2 V3
[1,]  4  4  4
[2,]  5  5  5
[3,]  6  6  6

[[3]]
   V1 V2 V3
[1,]  7  7  7
[2,]  8  8  8
[3,]  9  9  9

I'd like to calculate the moving average (interval = 2) i.e.

( x[[1]] + x[[2]] ) / 2
( x[[2]] + x[[3]] ) / 2
... and so on.

The desired output will return

2.5 2.5 2.5
3.5 3.5 3.5
4.5 4.5 4.5

5.5 5.5 5.5
6.5 6.5 6.5
7.5 7.5 7.5




Muhammad Rahiz  |  Doctoral Student in Regional Climate Modeling
Climate Research Laboratory, School of Geography & the Environment	
Oxford University Centre for the Environment, University of Oxford
South Parks Road, Oxford, OX1 3QY, United Kingdom
Tel: +44 (0)1865-285194	 Mobile: +44 (0)7854-625974
Email: muhammad.rahiz at ouce.ox.ac.uk
milton ruser wrote: