Description Usage Format Source References Examples
This data set provides monthly mean CO2 concentrations measured at Mauna Loa.
1 |
An object of class tbl_df
(inherits from tbl
, data.frame
) with 728 rows and 7 columns.
ftp://aftp.cmdl.noaa.gov/products/trends/co2/co2_mm_mlo.txt
Dr. Pieter Tans, NOAA/ESRL (https://www.esrl.noaa.gov/gmd/ccgg/trends/) and Dr. Ralph Keeling, Scripps Institution of Oceanography (http://scrippsco2.ucsd.edu/).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # use complete years only
CO2_complete <- filter(CO2, year >= 1959, year < 2018)
# convert to time series object
CO2_ts <- ts(data = CO2_complete$co2_interp, start = 1959, end = c(2017, 12), frequency = 12)
# detrend via STL method
CO2_stl <- stl(CO2_ts, s.window = 7)
CO2_detrended <- mutate(
CO2_complete,
seasonal = t(CO2_stl$time.series)[1, ],
trend = t(CO2_stl$time.series)[2, ],
remainder = t(CO2_stl$time.series)[3, ]
)
# plot
p1 <- ggplot(CO2_detrended, aes(date_dec, co2_interp)) +
geom_line()
p2 <- ggplot(CO2_detrended, aes(date_dec, seasonal)) +
geom_line()
p3 <- ggplot(CO2_detrended, aes(date_dec, trend)) +
geom_line()
p4 <- ggplot(CO2_detrended, aes(date_dec, remainder)) +
geom_line()
plot_grid(p1, p2, p3, p4, ncol = 1, align = 'v')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.