Get startedGet started for free

Review xts fundamentals

1. Review xts fundamentals

Before jumping in, lets review the fundamentals of time series data.

2. Time series data

Time series data contain observations of one or more units over many periods. Let's say you want to understand a city's population growth over time. You would measure the population each year to generate a dataset containing a column of years and a column of population figures.

3. What are xts objects?

Where does the xts package come in? xts facilitates the manipulation of time series data in R by producing xts objects, which consist of a matrix paired with a time index. Here you can see a standard matrix of numeric values in R - lets pretend these are city population data. To produce an xts object from this matrix, we simply attach a vector of dates. In this case, we'll attach years corresponding to population measures. While a regular data frame may contain a time variable, an xts object is indexed on time, making it easier to manipulate in interesting ways. For example, if we want to add a new row of data in the middle of the time period, xts knows to place this row between the nearest dates in the time index.

4. Flight data

In this chapter, you'll practice encoding and manipulating xts objects by exploring Boston area flight data, including information on flight delays and cancellations. As you work through these exercises, try to think like a data scientist. What information is contained in the data? And how can you manipulate the data to better reveal this information?

5. Let's practice!

OK, let's practice!