Time series
In this section, we will cover a special case of data you may find in R—the time series. This class of data is used in R to represent time data, such as hours, years, or dates in general. Of the data available in the R installation, there are some datasets containing time series, such as the UKgas
and economics
datasets. For our simple example, we will use the latter, which is a data frame containing population and employment information in the US over the last 40 years. You can find an overview of the dataset information in the help page at ?economics
.
Let's first have a look to the dataset and see its structure:
head(economics) date pce pop psavert uempmed unemploy 1 1967-06-30 507.8 198712 9.8 4.5 2944 2 1967-07-31 510.9 198911 ...
Get ggplot2 Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.