Creating a “zoo” object from OECD unemployment data

The data file “unemployment.csv” used below consists of data originally downloaded from the OECD Database website.

unemployment <- read.csv("unemployment.csv")

The following makes use of the zoo package. You may need to install it from CRAN using the code install.packages("zoo") if you want to run this on your computer. (The package is already installed on the notebook container, however.)

library(zoo)
Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric
unemployment.z <- zoo(unemployment[,2:7],
                      order.by=as.Date(
                          ISOdate(year=unemployment[,1],
                                  month=12,
                                  day=31)))
dim(unemployment.z)
[1] 30  6
class(unemployment.z)
[1] "zoo"
head(unemployment.z)
           Germany France Italy Netherlands Belgium Luxembourg
1970-12-31   0.557  2.477 4.000       0.868   1.913         NA
1971-12-31   0.689  2.712 4.001       1.213   1.848         NA
1972-12-31   0.912  2.806 4.711       2.114   2.350         NA
1973-12-31   1.000  2.690 4.691       2.151   2.408         NA
1974-12-31   2.132  2.853 3.942       2.624   2.523      0.067
1975-12-31   3.965  4.028 4.312       3.772   4.522      0.200
start(unemployment.z)
[1] "1970-12-31"
end(unemployment.z)
[1] "1999-12-31"
end(unemployment.z) - start(unemployment.z)
Time difference of 10592 days
# Saved for later use:
save(unemployment.z,file="unemployment-z.RData")