The zoo package is designed for use with (potentially irregular) time series data. It is widely used for any number of applications, but among its most frequently useful functions are the roll* functions, such as rollmean, rollmedian, rollmax, rollapply, etc.

Today’s Gist shows you how to use these rolling functions to summarize time series data across a moving window. That is, you can calculate any function on a 5-day (or second, or year) basis, across the length of the entire vector. This is certainly something that could be done with a simple loop, but the roll* functions make it easy and fast.

*Related*

To

**leave a comment** for the author, please follow the link and comment on their blog:

** is.R()**.

R-bloggers.com offers

**daily e-mail updates** about

R news and

tutorials on topics such as:

Data science,

Big Data, R jobs, visualization (

ggplot2,

Boxplots,

maps,

animation), programming (

RStudio,

Sweave,

LaTeX,

SQL,

Eclipse,

git,

hadoop,

Web Scraping) statistics (

regression,

PCA,

time series,

trading) and more...

If you got this far, why not

__subscribe for updates__ from the site? Choose your flavor:

e-mail,

twitter,

RSS, or

facebook...