emissions_dataset_full <- folder_path("emissions_dataset.rds") %>%
read_rds()
imf_wb_country_groups <- folder_path("imf_wb_country_groups.rds") %>%
read_rds()
First, we can look at cumulative CO2 emissions and the emitters separately by their country groups, advanced or emerging. Before doing that, we need to clean up the country names as the country names in the two datasets are not in coordination.
iso3c_to_country_name <- function(iso3c) {
iso3c %>%
countrycode(origin = "iso3c", destination = "country.name")
}
cleaned_names <- emissions_dataset_full %>%
mutate(country_name = iso3c_to_country_name(iso3c))
With cleaned names dataset, we can now merge the two datasets and filter for advanced economies’ CO2 emissions.
adv_emissions_2019 <- cleaned_names %>%
left_join(imf_wb_country_groups, by = "country_name") %>%
filter(country_group == "Advanced Economies", year == 2019) %>%
group_by(country_name) %>%
summarize(tot_co2 = sum(cumulative_co2)) %>%
arrange(desc(tot_co2))
We can now ask R to help us draw a chart, showing the top 5 emitters in the advanced economies.
adv_emissions_2019 %>%
slice(1:5) %>%
ggplot(aes(fct_reorder(country_name, tot_co2), tot_co2)) +
geom_col(fill = "#1565C0") +
coord_flip() +
scale_x_discrete(guide = guide_axis(n.dodge = 1.5)) +
scale_y_continuous(labels = comma) +
labs(x = " ",
y = "Total CO2 emission",
title = "Top 5: Total CO2 emissions for advanced economies",
caption = "Source: IMF & World Bank") +
theme_minimal()
We then do the same things for the emerging markets.
em_emissions_2019 <- cleaned_names %>%
left_join(imf_wb_country_groups, by = "country_name") %>%
filter(country_group == "Emerging Market Economies", year == 2019) %>%
group_by(country_name) %>%
summarize(tot_co2 = sum(cumulative_co2)) %>%
arrange(desc(tot_co2))
em_emissions_2019 %>%
slice(1:5) %>%
ggplot(aes(fct_reorder(country_name, tot_co2), tot_co2)) +
geom_col(fill = "#1E88E5") +
coord_flip() +
scale_x_discrete(guide = guide_axis(n.dodge = 1.5)) +
scale_y_continuous(label = comma) +
labs(x = " ",
y = "Total CO2 emission",
title = "Top 5: Total CO2 emissions for emerging markets",
caption = "Source: IMF & World Bank") +
theme_minimal()
We can also put the two types of economies together to better compare them.
by_ae_em <- cleaned_names %>%
left_join(imf_wb_country_groups, by = "country_name") %>%
filter(country_group == "Advanced Economies" | country_group == "Emerging Market Economies", year == 2019) %>%
group_by(country_group)
by_ae_em_clean <- by_ae_em %>%
filter(!is.na(consumption_co2_per_capita)) %>%
filter(!is.na(debt_pct_gdp))
ggplot(by_ae_em_clean, aes(x = consumption_co2_per_capita, y = debt_pct_gdp, color = country_group, size = gdp_usd_current_prices)) +
geom_point() +
labs(x = "CO2 Consumption Per Capita",
y = "Debt % GDP",
title = "CO2 Consumption & Debt",
caption = "Source: IMF & World Bank")