Looking at emissions through a few different lenses

First, a deeper look into the different inputs to a country’s emissions.

We looked in class at CO2 emissions per capita in emerging vs. developed economies in terms of cumulative CO2 consumption per capita. I wanted to break down some of that nuance a little further by looking into trade-based, consumption-based, and territorial CO2 emissions per capita, on average, in developed vs. emerging economies.

#Determine average per capital co2 emissions by category of emissions for developed vs. emerging economies every year
  emissions_by_type <- emissions_dataset %>%
  #compare for emerging markets and developed markets every year
  group_by(em_dm, year) %>%
  #take the average per capita co2 for each category, removing missing values from the analysis
  summarize(avg_territorial_co2_per_capita = mean(territorial_co2_per_capita, na.rm = TRUE), avg_trade_co2_per_capita = mean(trade_co2_per_capita, na.rm = TRUE), avg_consumption_co2_per_capita = mean(consumption_co2_per_capita, na.rm = TRUE), avg_cum_co2_per_capita = mean(cumulative_co2_per_capita, na.rm = TRUE))
## `summarise()` has grouped output by 'em_dm'. You can override using the
## `.groups` argument.
#for the sake of visualization, I want to look at one year of data, so I will limit this data and pivot it into an easier format to make a graphic
emissions_by_type_2019 <- emissions_by_type %>% 
  #filter by 2019 when we have more data, keep simple
  filter(year == 2019) %>%
  #pivot longer to get data into shape for bar chart
  pivot_longer(avg_territorial_co2_per_capita:avg_consumption_co2_per_capita) 


#compare emerging and developed markets' co2 emissions by category in 2019, visually
ggplot(emissions_by_type_2019) +
  aes(x = name, fill = em_dm, weight = value) +
  geom_bar(position = "dodge") +
  labs(x = "Category of CO2 Emissions", y = "Average Per Capita Tons CO2 Emissions", title = "Sources of Emissions in Emerging and Developed Markets") +
  labs(color = "Economy Type") +
  #change labels of bars
    scale_x_discrete(labels = c('Consumption','Territorial','Trade')) + 
  scale_fill_hue(direction = 1) +
  theme(axis.text.x = element_text(size = 10))

# Cumulative Emissions Over Time ## How long has the gap between developed and emerging economies been this large?

We have seen above the large difference in emerging and developed economies when it comes to different components of cumulative per capita CO2 emissions. We will go beyond the emerging and developing economy categorization and look at the trajectory of emissions over the past 30 years using World Bank Income Group Designation.

emissions_by_wb_group <- wb_income_groups %>% 
  inner_join(emissions_dataset, by = c("country_name")) %>%
  group_by(wb_income_group, year) %>%
  summarize(avg_emissions = mean(cumulative_co2_per_capita, na.rm = TRUE)) %>%
  arrange(desc(avg_emissions)) 
## `summarise()` has grouped output by 'wb_income_group'. You can override using
## the `.groups` argument.
#check out data structure and confirm things look ok
print(emissions_by_wb_group)
## # A tibble: 120 × 3
## # Groups:   wb_income_group [4]
##    wb_income_group  year avg_emissions
##    <fct>           <dbl>         <dbl>
##  1 High             2019          580.
##  2 High             2018          574.
##  3 High             2017          567.
##  4 High             2016          561.
##  5 High             2015          556.
##  6 High             2014          551.
##  7 High             2013          546.
##  8 High             2012          540.
##  9 High             2011          533.
## 10 High             2010          525.
## # … with 110 more rows
ggplot(emissions_by_wb_group) +
  aes(x = year, y = avg_emissions, colour = wb_income_group) +
  geom_line(size = 0.5) +
  scale_color_manual(
    values = c(High = "#F8766D",
    `Upper Middle` = "#31B425",
    `Lower Middle` = "#20AFEC",
    Low = "#FF61C3")
  ) +
  labs(
    x = "Year",
    y = "Cumulative CO2 Emissions Per Capita (Average)",
    title = "Emissions Per Capita by Income Group",
    subtitle = "Using World Bank Income Groups",
    caption = "Sources: World Bank, Our World in Data",
    color = "World Bank Country Group") +
  theme_minimal()

# Cumulative Emissions Over in Developed Economies ## Who are the biggest of the biggest emitters?

We have established both here and through the examples in class that high income countries have much higher cumulative emissions than lower income countries. We will use the more detailed economic group distinctions from the IMF groups to see how this differs among developed economies.

emissions_by_imf_group <- imf_wb_country_groups %>% 
  inner_join(emissions_dataset, by = c("country_name")) %>%
  filter(group_type == "IMF") %>%
  group_by(country_group, year) %>%
  summarize(avg_emissions = mean(cumulative_co2_per_capita, na.rm = TRUE)) %>%
  arrange(desc(avg_emissions)) 
## `summarise()` has grouped output by 'country_group'. You can override using the
## `.groups` argument.
#check out data structure and confirm things look ok
print(emissions_by_imf_group)
## # A tibble: 510 × 3
## # Groups:   country_group [17]
##    country_group  year avg_emissions
##    <chr>         <dbl>         <dbl>
##  1 G7             2019          846.
##  2 G7             2018          840.
##  3 G7             2017          835.
##  4 G7             2016          829.
##  5 G7             2015          825.
##  6 G7             2014          820.
##  7 G7             2013          814.
##  8 G7             2012          808.
##  9 G7             2011          802.
## 10 G7             2010          796.
## # … with 500 more rows
emissions_by_imf_group %>%
  #only look at developed economy groups
 filter(country_group %in% c("G7", "Advanced G20", "Advanced Economies", "Euro Area", 
"G20")) %>%
 ggplot() +
 aes(x = year, y = avg_emissions, colour = country_group) +
 geom_line(size = 0.5) +
 scale_color_hue(direction = 1) +
 labs(x = "Year", y = "Cumulative CO2 Emissions Per Capita (Average)", title = "Emissions Per Capita by Income Group",
 subtitle = "Using IMF Income Groups", caption = "Sources: Our World in Data, IMF", color = "IMF Country Group") +
 theme_minimal()