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 9.8 4.7 2945 3 1967-08-31 516.7 199113 9.0 4.6 2958 4 1967-09-30 513.3 199311 9.8 4.9 3143...