For the purpose of comparison with STL decomposition we showcase the elimination of a linear trend and seasonal effects on carbon dioxide (CO2) data taken at the Mauna Loa Observatory in Hawaii

First, we load the Keeling Curve. The data is provided by Dr. Pieter Tans, NOAA/ESRL and Dr. Ralph Keeling, Scripps Institution of Oceanography. Revisit the section on Data sets used to remind yourself how to download and extract the data set of interest.


For the purpose of demonstration we focus on the period from 1990 to 2015. We subset the time series by applying the window() function.

co2.1990.2015 <- window(co2, 
                        start = "1990-01-01", 
                        end = "2015-12-31")
     type = 'o', 
     cex = 0.5, 
     ylab = expression("CO"[2]*" ppm"),
     main = expression("CO"[2]*" Concentration at Mauna Loa Observatory, Hawaii (1990-2015)"), 
     cex.main = 0.85)

Finally, we store the time series data set in a .RData file for further processing.

save(file = "KeelingCurve_1990-2015.RData", co2.1990.2015)