[R] Calculating variances in a moving window

Gabor Grothendieck ggrothendieck at gmail.com
Thu Oct 21 23:44:36 CEST 2010


On Thu, Oct 21, 2010 at 5:30 PM, Philippe Hensel
<Philippe.Hensel at noaa.gov> wrote:
> I am trying to create basic descriptive statistics for a spatial dataset
> using moving windows of variable sizes.
>
> I found the filter(dataset, rep(1/a,1)) very useful for obtaining averages
> for a given moving window size "a"
> (a is the window size within a column of data in a matrix - the filter is
> applied to all columns automatically)
>
> I could not find anything analogous for calculating variances over a moving
> window.  Is there one available?
> Otherwise, I'm slowly cranking away on making my own, but it's quite
> tedious!
>

rollapply in the zoo package can take an arbitrary R function.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list