Manipulating Time Series Data in R
Build zoo time series in R, subset and resample them, fill missing values, and compute rolling and expanding window statistics in interactive exercises.
Time series data is data that changes over time, and R has its own temporal classes and packages for summarizing, plotting and reshaping it. Overall figures such as a mean or a sum do not always show how a series moves, and a long timespan can clutter a plot with more than you need. You build and inspect zoo objects, keep dates consistent with lubridate, pick out the period that matters, fill gaps in the record and compute statistics that follow the data as it changes.
What You Will Achieve
- Plot a series with autoplot and read its patterns while exploring a new dataset
- Create zoo objects, check their sampling frequency and time range, and move them to and from data frames
- Narrow a series to a chosen period, resample it to monthly or quarterly levels, and fill missing values with constant fill, LOCF or linear interpolation
- Calculate rolling and expanding statistics, such as a rolling minimum or an expanding mean, to track change across time
Program Overview
Time Series Basics and Dates in R
Defines a time series, shows how to summarize and plot one, and handles the classes and formats R uses for dates.
- Time series summaries and autoplot
- Interpreting time series plots
- Temporal data classes and is-dot functions
- Parsing and formatting dates with lubridate
Time Series Attributes and zoo Objects
Reads the range and sampling rate of a series and works with zoo objects, including their indices and data frame conversion.
- Temporal attributes and decimal dates
- Creating zoo objects and plotting them with ggplot2
- Updating indices and finding overlapping indices
- Converting between zoo and data frames
Indexing, Imputation, and Window Statistics
Selects windows and dates, aggregates observations, imputes missing values, then applies rolling and expanding window functions.
- Subsetting windows with yearmon and yearqtr
- Resampling and custom aggregation levels
- Constant fill, LOCF and linear interpolation
- Rolling and expanding window functions
Certificate Awarded (Paid)
Job Outlook
Handling time series in R is part of analysis and data science work wherever data is recorded over time, such as sales tracked over several weeks or readings sampled every minute or hour.
Good for: Analysts working in R who need to subset, aggregate and summarize data recorded over time, such as weekly sales figures.
Keep in mind: Despite its intermediate label, it starts from what a time series is and treats the topic as new; most of the work runs on zoo objects.
Bottom line: Its closing chapter on rolling and expanding windows turns single overall summaries into statistics that follow a series as it moves.
Frequently Asked Questions
Which R packages does the course use?
Most of the work runs on zoo objects, with lubridate for parsing and formatting dates and ggplot2 for plotting. The xts package comes in when observations are aggregated to show broader trends in the data.
What is the difference between rolling and expanding windows?
A rolling window moves along the series and recomputes a statistic, such as a minimum or a custom function, over each stretch of observations. An expanding window keeps growing, so an expanding sum or mean shows how the statistic approaches its final value.
Why convert between zoo objects and data frames?
Many data science applications in R are built around the data frame layout. The course shows how to move a series from a zoo object into a data frame and back, so time series work fits alongside those tools.
How does the course handle monthly and quarterly data?
The zoo yearmon and yearqtr classes represent monthly and quarterly periods. Observations can be resampled and aggregated to these levels or to a custom level, and the aggregated series can then be plotted with ggplot2.


There are no reviews yet.