Visualizing time-series

This is in a very familiar data structure: 365 rows for each day in 2011 and five columns to store the four metrics for the dates stored in the first variable. Let's transform that to a time-series object and plot it right away:

> plot(ts(daily))
Visualizing time-series

It was easy, right? We have just plotted several independent time-series on a line chart. But what's shown on the first plot? The x axis is indexed from 1 to 365 because ts did not automatically identify that the first column stores our dates. On the other hand, we find the date transformed to timestamps on the y axis. Shouldn't the points form a linear line?

This is one of the beauties of data visualization: a simple plot revealed a major issue with our data. It seems we have to sort the data by date:

> setorder(daily, date)
> plot(ts(daily))
Visualizing time-series

Much better! Now that the values are in the right order, we can focus on the actual time-series data one by one at a time. First let's see how the number of flights looked from the first day of 2011 with a daily frequency:

> plot(ts(daily$N, start = 2011, frequency = 365),
+      main = 'Number of flights from Houston in 2011')
Visualizing time-series
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.24.180