-
-
Save gka/db4d4a1e2515ae10d8b93d54a60a75ce to your computer and use it in GitHub Desktop.
Script to update the "Six Decades of Carbon Dioxide Concentration in the Atmosphere" chart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
needs(tidyverse) | |
co2 <- read_table('ftp://aftp.cmdl.noaa.gov/products/trends/co2/co2_mm_mlo.txt', comment = '#', | |
col_names = c('year','month','date','average','interpolated','trend')) %>% | |
transmute(year, month, date=as.Date(paste(year, month, 1, sep='/')), average, interpolated) | |
co2_wide <- co2 %>% | |
mutate(decade=(year-(year %% 10)), | |
year.into.decade=year-decade+month/12) %>% | |
select(year.into.decade, decade, average) | |
co2_wide.copy <- co2_wide %>% | |
filter(year.into.decade==10) %>% | |
mutate(year.into.decade=0, decade=decade+10) | |
co2_wide %>% | |
bind_rows(co2_wide.copy) %>% | |
pivot_wider(names_from = decade, values_from=average) %>% | |
arrange(year.into.decade) %>% | |
write_tsv('co-dedaces.tsv', na='') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment