Skip to content
Prev 175456 / 398506 Next

Sliding window over irregular intervals

The window you describe is not one I would call sliding and the  
intervals are regular with an irregular number of events within the  
windows. One way would be to use the results of trunc(pos/10000) as a  
factor with tapply:

(Related functions are floor() and round(), but your pos values appear  
to be positive, so there should not be problems with how they work  
across 0)

After creating a dataframe, dta, try something like:

 > tapply(dta$xpehh, as.factor(trunc(dta$pos/10000)), min)
      1579      1580      1581      1582
-0.153413 -0.367296  0.302555  0.090302