Data Analysis 7

Author

Joe Aumuller

Loading Libraries for Analysis & Country Code Fx

Packages below are to help “tidy” the data within the tidyverse packages as well as incorporate geospatial data identifiers like iso3c country codes for joining different data tables. Additionally a country code function has been added to facilitate faster transformations of country level data.

Show the code
#| echo: false
#| warning: false

#load libraries for use

setwd("C:/Users/joeau/OneDrive - Johns Hopkins/SAIS/Year 2/Sustainable Finance/sais_sustainable_finance/week_7")

library(tidyverse)
Warning: package 'tidyverse' was built under R version 4.2.2
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.0     ✔ purrr   1.0.1
✔ tibble  3.1.8     ✔ dplyr   1.1.0
✔ tidyr   1.3.0     ✔ stringr 1.5.0
✔ readr   2.1.3     ✔ forcats 1.0.0
Warning: package 'ggplot2' was built under R version 4.2.2
Warning: package 'tidyr' was built under R version 4.2.2
Warning: package 'readr' was built under R version 4.2.2
Warning: package 'purrr' was built under R version 4.2.2
Warning: package 'dplyr' was built under R version 4.2.2
Warning: package 'stringr' was built under R version 4.2.2
Warning: package 'forcats' was built under R version 4.2.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
Show the code
library(purrr)
library(janitor)
Warning: package 'janitor' was built under R version 4.2.2

Attaching package: 'janitor'

The following objects are masked from 'package:stats':

    chisq.test, fisher.test
Show the code
library(here)
Warning: package 'here' was built under R version 4.2.2
here() starts at C:/Users/joeau/OneDrive - Johns Hopkins/SAIS/Year 2/Sustainable Finance/sais_sustainable_finance
Show the code
library(readxl)
Warning: package 'readxl' was built under R version 4.2.2
Show the code
library(rnaturalearth)
Warning: package 'rnaturalearth' was built under R version 4.2.2
Show the code
library(countrycode)
Warning: package 'countrycode' was built under R version 4.2.2
Show the code
library(wbstats)
Warning: package 'wbstats' was built under R version 4.2.2
Show the code
library(broom)
Warning: package 'broom' was built under R version 4.2.2
Show the code
#| echo: false
#| warning: false

#build functions to help generate locations

country_name_regex_to_iso3c <- function(country_name) {
  country_name |>
    countrycode(origin = "country.name", 
                                     destination = "iso3c",
                                     origin_regex = TRUE)
}

iso3c_to_country_name <- function(country_string) {
  country_string %>%
    countrycode::countrycode(origin = "iso3c", destination = "country.name")
} 

character_num_to_numeric <- function(character_num) {
  character_num %>%
  # take out the commas
  stringr::str_remove_all(pattern = ",") %>%
  # take out any blank spaces before or after the number
  stringr::str_trim() %>%
  # coerce to numeric
  as.numeric()
}

iso3c_to_x <- purrr::partial(countrycode, origin = "iso3c")

Loading in CO2 Emissions Data

Show the code
country_co2 <- read_csv("ghg-emissions.csv") |> 
  gather(Year, co2_em, '1990':'2018') |> 
  rename("country" = "Country/Region", "year" = "Year") |> 
  filter('country' != "Data Source")
Rows: 195 Columns: 31
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr  (3): Country/Region, unit, 1990
dbl (28): 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, ...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Show the code
scope <- country_co2 |>
  mutate(iso3c = country_name_regex_to_iso3c(country)) |>
  mutate(country_name = iso3c_to_country_name(iso3c)) |> 
  mutate(flag = iso3c_to_x(iso3c, destination = "unicode.symbol")) |>
  relocate(iso3c, country_name, flag, .after = country) |> 
  mutate(across(.cols = c("year","co2_em"), .fns = character_num_to_numeric))
Warning: There was 1 warning in `mutate()`.
ℹ In argument: `iso3c = country_name_regex_to_iso3c(country)`.
Caused by warning in `countrycode_convert()`:
! Some values were not matched unambiguously: Data for, Data source, Micronesia
Warning: There was 1 warning in `mutate()`.
ℹ In argument: `across(.cols = c("year", "co2_em"), .fns =
  character_num_to_numeric)`.
Caused by warning in `character_num %>% stringr::str_remove_all(pattern = ",") %>% stringr::str_trim() %>%
    as.numeric()`:
! NAs introduced by coercion
Show the code
scope
# A tibble: 5,655 × 7
   country       iso3c country_name  flag                   unit    year co2_em
   <chr>         <chr> <chr>         <chr>                  <chr>  <dbl>  <dbl>
 1 China         CHN   China         "\U0001f1e8\U0001f1f3" MtCO2e  1990  2892.
 2 United States USA   United States "\U0001f1fa\U0001f1f8" MtCO2e  1990  5417.
 3 India         IND   India         "\U0001f1ee\U0001f1f3" MtCO2e  1990  1003.
 4 Indonesia     IDN   Indonesia     "\U0001f1ee\U0001f1e9" MtCO2e  1990  1227.
 5 Russia        RUS   Russia        "\U0001f1f7\U0001f1fa" MtCO2e  1990  2648.
 6 Brazil        BRA   Brazil        "\U0001f1e7\U0001f1f7" MtCO2e  1990  1639.
 7 Japan         JPN   Japan         "\U0001f1ef\U0001f1f5" MtCO2e  1990  1106.
 8 Iran          IRN   Iran          "\U0001f1ee\U0001f1f7" MtCO2e  1990   304.
 9 Canada        CAN   Canada        "\U0001f1e8\U0001f1e6" MtCO2e  1990   607.
10 Saudi Arabia  SAU   Saudi Arabia  "\U0001f1f8\U0001f1e6" MtCO2e  1990   241.
# … with 5,645 more rows
# A tibble: 2,064 × 6
   code    country                year country_ghg_all iso3c country_name
   <chr>   <chr>                 <dbl>           <dbl> <chr> <chr>       
 1 Country <NA>                   1995            NA   <NA>  <NA>        
 2 WLD     World                  1995         21367.  <NA>  <NA>        
 3 OECD    OECD member countries  1995         13016.  <NA>  <NA>        
 4 AUS     Australia              1995           278   AUS   Australia   
 5 AUT     Austria                1995            85.1 AUT   Austria     
 6 BEL     Belgium                1995           130.  BEL   Belgium     
 7 CAN     Canada                 1995           409.  CAN   Canada      
 8 CHL     Chile                  1995            39.9 CHL   Chile       
 9 COL     Colombia               1995            65.5 COL   Colombia    
10 CRI     Costa Rica             1995             8.1 CRI   Costa Rica  
# … with 2,054 more rows
Show the code
#| echo: false
#| warning: false

#Joining OECD SCope 1 to Sovereign Debt Table

em_trade_less <- em_trade |> 
  select(-c('code', 'country', 'country_name'))

scope_1 <- scope |> 
  inner_join(em_trade_less, by = c("iso3c", "year")) |> 
  rowwise() |> 
  mutate(scope1 = sum(c_across(co2_em:country_ghg_all)))
Warning in inner_join(scope, em_trade_less, by = c("iso3c", "year")): Each row in `x` is expected to match at most 1 row in `y`.
ℹ Row 1160 of `x` matches multiple rows.
ℹ If multiple matches are expected, set `multiple = "all"` to silence this
  warning.
Show the code
scope_1
# A tibble: 3,024 × 9
# Rowwise: 
   country       iso3c country_name  flag      unit   year co2_em count…¹ scope1
   <chr>         <chr> <chr>         <chr>     <chr> <dbl>  <dbl>   <dbl>  <dbl>
 1 China         CHN   China         "\U0001f… MtCO…  1995  3961.   2614.  6574.
 2 United States USA   United States "\U0001f… MtCO…  1995  5730.   5374. 11103.
 3 India         IND   India         "\U0001f… MtCO…  1995  1224.    672.  1895.
 4 Indonesia     IDN   Indonesia     "\U0001f… MtCO…  1995  1339.    203.  1542.
 5 Russia        RUS   Russia        "\U0001f… MtCO…  1995  1918.   1026.  2944.
 6 Brazil        BRA   Brazil        "\U0001f… MtCO…  1995  1725.    250.  1975.
 7 Japan         JPN   Japan         "\U0001f… MtCO…  1995  1201.   1502.  2704.
 8 Canada        CAN   Canada        "\U0001f… MtCO…  1995   646.    409.  1055.
 9 Saudi Arabia  SAU   Saudi Arabia  "\U0001f… MtCO…  1995   289.    198    487.
10 Germany       DEU   Germany       "\U0001f… MtCO…  1995   982.   1072.  2055.
# … with 3,014 more rows, and abbreviated variable name ¹​country_ghg_all
Show the code
#| echo: false
#| warning: false

#Bring in Category D35 "Energy Imports" from OECD Emissions Table for Scope 2

setwd("C:/Users/joeau/OneDrive - Johns Hopkins/SAIS/Year 2/Sustainable Finance/sais_sustainable_finance/week_7")

scope_2_raw <- read_csv("scope_2.csv", skip = 6) |> 
  gather(Year, scope2, '1995':'2018')|> 
  select(-c(2)) |> 
  separate(col = Time, into = c("code", "country"), sep=': ') |> 
  mutate(iso3c = country_name_regex_to_iso3c(country)) |>
  mutate(country_name = iso3c_to_country_name(iso3c)) |> 
  filter('code' != "Country") |> 
  rename("year" = "Year") |>
  mutate(across(.cols = c("year"), .fns = character_num_to_numeric))
New names:
Rows: 80 Columns: 26
── Column specification
──────────────────────────────────────────────────────── Delimiter: "," chr
(1): Time dbl (24): 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
2005, ... lgl (1): ...2
ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
Specify the column types or set `show_col_types = FALSE` to quiet this message.
• `` -> `...2`
Warning: Expected 2 pieces. Missing pieces filled with `NA` in 48 rows [1, 80, 81, 160,
161, 240, 241, 320, 321, 400, 401, 480, 481, 560, 561, 640, 641, 720, 721, 800,
...].
Warning: There was 1 warning in `mutate()`.
ℹ In argument: `iso3c = country_name_regex_to_iso3c(country)`.
Caused by warning in `countrycode_convert()`:
! Some values were not matched unambiguously: Asia-Pacific Economic Cooperation, Association of South East Asian Nations, Eastern Asia, EU28 excluding EU15, Euro area (19 countries), European Union (15 countries), European Union (27 countries), European Union (28 countries), Group of Twenty, Non-OECD economies and aggregates, OECD member countries, Rest of the World, Türkiye
Show the code
scope_2_raw
# A tibble: 1,920 × 6
   code    country                year scope2 iso3c country_name
   <chr>   <chr>                 <dbl>  <dbl> <chr> <chr>       
 1 Country <NA>                   1995   NA   <NA>  <NA>        
 2 OECD    OECD member countries  1995   10.1 <NA>  <NA>        
 3 AUS     Australia              1995    0.2 AUS   Australia   
 4 AUT     Austria                1995    0.6 AUT   Austria     
 5 BEL     Belgium                1995    1.4 BEL   Belgium     
 6 CAN     Canada                 1995   15   CAN   Canada      
 7 CHL     Chile                  1995    0   CHL   Chile       
 8 COL     Colombia               1995    0.1 COL   Colombia    
 9 CRI     Costa Rica             1995    0   CRI   Costa Rica  
10 CZE     Czech Republic         1995    0.3 CZE   Czechia     
# … with 1,910 more rows
Show the code
#| echo: false
#| warning: false

#Joining OECD SCope 2 to Sovereign Debt Table

scope_2 <- scope_2_raw |> 
  select(-c('code', 'country', 'country_name'))

scope_1_2 <- scope_1 |> 
  inner_join(scope_2, by = c("iso3c", "year")) |> 
  rowwise() |> 
  mutate(scope1 = sum(c_across(co2_em:country_ghg_all)))
Warning in inner_join(scope_1, scope_2, by = c("iso3c", "year")): Each row in `x` is expected to match at most 1 row in `y`.
ℹ Row 64 of `x` matches multiple rows.
ℹ If multiple matches are expected, set `multiple = "all"` to silence this
  warning.
Show the code
scope_1_2
# A tibble: 24,192 × 10
# Rowwise: 
   country       iso3c country_…¹ flag  unit   year co2_em count…² scope1 scope2
   <chr>         <chr> <chr>      <chr> <chr> <dbl>  <dbl>   <dbl>  <dbl>  <dbl>
 1 China         CHN   China      "\U0… MtCO…  1995  3961.   2614.  6574.    1.1
 2 United States USA   United St… "\U0… MtCO…  1995  5730.   5374. 11103.    6.4
 3 India         IND   India      "\U0… MtCO…  1995  1224.    672.  1895.    0.2
 4 Indonesia     IDN   Indonesia  "\U0… MtCO…  1995  1339.    203.  1542.    0.1
 5 Russia        RUS   Russia     "\U0… MtCO…  1995  1918.   1026.  2944.    1.5
 6 Brazil        BRA   Brazil     "\U0… MtCO…  1995  1725.    250.  1975.    4  
 7 Japan         JPN   Japan      "\U0… MtCO…  1995  1201.   1502.  2704.    1.5
 8 Canada        CAN   Canada     "\U0… MtCO…  1995   646.    409.  1055.   15  
 9 Saudi Arabia  SAU   Saudi Ara… "\U0… MtCO…  1995   289.    198    487.    0.1
10 Germany       DEU   Germany    "\U0… MtCO…  1995   982.   1072.  2055.    4.3
# … with 24,182 more rows, and abbreviated variable names ¹​country_name,
#   ²​country_ghg_all
# A tibble: 1,920 × 6
   code    country                year scope_3_gross iso3c country_name
   <chr>   <chr>                 <dbl>         <dbl> <chr> <chr>       
 1 Country <NA>                   1995          NA   <NA>  <NA>        
 2 OECD    OECD member countries  1995        1591.  <NA>  <NA>        
 3 AUS     Australia              1995          62   AUS   Australia   
 4 AUT     Austria                1995          53.5 AUT   Austria     
 5 BEL     Belgium                1995          96.4 BEL   Belgium     
 6 CAN     Canada                 1995         164.  CAN   Canada      
 7 CHL     Chile                  1995          14.1 CHL   Chile       
 8 COL     Colombia               1995          21.7 COL   Colombia    
 9 CRI     Costa Rica             1995           5.7 CRI   Costa Rica  
10 CZE     Czech Republic         1995          27.8 CZE   Czechia     
# … with 1,910 more rows
# A tibble: 341,712 × 12
# Rowwise: 
   country  iso3c count…¹ flag  unit   year co2_em count…² scope1 scope2 scope…³
   <chr>    <chr> <chr>   <chr> <chr> <dbl>  <dbl>   <dbl>  <dbl>  <dbl>   <dbl>
 1 China    CHN   China   "\U0… MtCO…  1995  3961.   2614.  6574.    1.1   117. 
 2 United … USA   United… "\U0… MtCO…  1995  5730.   5374. 11103.    6.4   787. 
 3 India    IND   India   "\U0… MtCO…  1995  1224.    672.  1895.    0.2    47.5
 4 Indones… IDN   Indone… "\U0… MtCO…  1995  1339.    203.  1542.    0.1    56  
 5 Russia   RUS   Russia  "\U0… MtCO…  1995  1918.   1026.  2944.    1.5    76.1
 6 Brazil   BRA   Brazil  "\U0… MtCO…  1995  1725.    250.  1975.    4      57.4
 7 Japan    JPN   Japan   "\U0… MtCO…  1995  1201.   1502.  2704.    1.5   480. 
 8 Canada   CAN   Canada  "\U0… MtCO…  1995   646.    409.  1055.   15     164. 
 9 Saudi A… SAU   Saudi … "\U0… MtCO…  1995   289.    198    487.    0.1    30.3
10 Germany  DEU   Germany "\U0… MtCO…  1995   982.   1072.  2055.    4.3   426. 
# … with 341,702 more rows, 1 more variable: scope3 <dbl>, and abbreviated
#   variable names ¹​country_name, ²​country_ghg_all, ³​scope_3_gross
# A tibble: 341,712 × 11
# Rowwise: 
   country   iso3c count…¹ flag  unit   year co2_em count…² scope1 scope2 scope3
   <chr>     <chr> <chr>   <chr> <chr> <dbl>  <dbl>   <dbl>  <dbl>  <dbl>  <dbl>
 1 China     CHN   China   "\U0… MtCO…  1995  3961.   2614.  6574.    1.1  116  
 2 United S… USA   United… "\U0… MtCO…  1995  5730.   5374. 11103.    6.4  780. 
 3 India     IND   India   "\U0… MtCO…  1995  1224.    672.  1895.    0.2   47.3
 4 Indonesia IDN   Indone… "\U0… MtCO…  1995  1339.    203.  1542.    0.1   55.9
 5 Russia    RUS   Russia  "\U0… MtCO…  1995  1918.   1026.  2944.    1.5   74.6
 6 Brazil    BRA   Brazil  "\U0… MtCO…  1995  1725.    250.  1975.    4     53.4
 7 Japan     JPN   Japan   "\U0… MtCO…  1995  1201.   1502.  2704.    1.5  478  
 8 Canada    CAN   Canada  "\U0… MtCO…  1995   646.    409.  1055.   15    149. 
 9 Saudi Ar… SAU   Saudi … "\U0… MtCO…  1995   289.    198    487.    0.1   30.2
10 Germany   DEU   Germany "\U0… MtCO…  1995   982.   1072.  2055.    4.3  422. 
# … with 341,702 more rows, and abbreviated variable names ¹​country_name,
#   ²​country_ghg_all
Show the code
## Join in relevant WB data

scope_1_2_3_wbnominal<-scope_1_2_3 |> 
  inner_join(wb_gdp_nominal_clean)
Show the code
sov_debt_1_2_3_allgdp<-scope_1_2_3_wbnominal |> 
  inner_join(wb_gdp_ppp_clean)
Show the code
sov_debt<-sov_debt_1_2_3_allgdp |> 
  inner_join(wb_population_clean) |> 
  rename(gdp = 'NY.GDP.MKTP.CD', gdp_ppp = 'NY.GDP.MKTP.PP.CD', total_pop = 'SP.POP.TOTL')

Exploring New PCAF Data

Show the code
#View Joined PCAF Data Set

sov_debt
# A tibble: 1,368 × 14
# Rowwise: 
   country   iso3c count…¹ flag  unit   year co2_em count…² scope1 scope2 scope3
   <chr>     <chr> <chr>   <chr> <chr> <dbl>  <dbl>   <dbl>  <dbl>  <dbl>  <dbl>
 1 China     CHN   China   "\U0… MtCO…  1995  3961.   2614.  6574.    1.1  116  
 2 United S… USA   United… "\U0… MtCO…  1995  5730.   5374. 11103.    6.4  780. 
 3 India     IND   India   "\U0… MtCO…  1995  1224.    672.  1895.    0.2   47.3
 4 Indonesia IDN   Indone… "\U0… MtCO…  1995  1339.    203.  1542.    0.1   55.9
 5 Brazil    BRA   Brazil  "\U0… MtCO…  1995  1725.    250.  1975.    4     53.4
 6 Japan     JPN   Japan   "\U0… MtCO…  1995  1201.   1502.  2704.    1.5  478  
 7 Canada    CAN   Canada  "\U0… MtCO…  1995   646.    409.  1055.   15    149. 
 8 Saudi Ar… SAU   Saudi … "\U0… MtCO…  1995   289.    198    487.    0.1   30.2
 9 Germany   DEU   Germany "\U0… MtCO…  1995   982.   1072.  2055.    4.3  422. 
10 Mexico    MEX   Mexico  "\U0… MtCO…  1995   471.    288    759.    0.2   59.6
# … with 1,358 more rows, 3 more variables: gdp <dbl>, gdp_ppp <dbl>,
#   total_pop <dbl>, and abbreviated variable names ¹​country_name,
#   ²​country_ghg_all

Clean Up Data

Show the code
#Tidy Emissions

EDA <- sov_debt |> 
  gather(PCAF_scope, PCAF_em, scope1:scope3) |> 
  gather(GDP_type, GDP_measure, gdp:gdp_ppp)
Warning: attributes are not identical across measure variables; they will be
dropped
Show the code
EDA
# A tibble: 8,208 × 13
   country       iso3c countr…¹ flag  unit   year co2_em count…² total…³ PCAF_…⁴
   <chr>         <chr> <chr>    <chr> <chr> <dbl>  <dbl>   <dbl>   <dbl> <chr>  
 1 China         CHN   China    "\U0… MtCO…  1995  3961.   2614.  1.20e9 scope1 
 2 United States USA   United … "\U0… MtCO…  1995  5730.   5374.  2.66e8 scope1 
 3 India         IND   India    "\U0… MtCO…  1995  1224.    672.  9.64e8 scope1 
 4 Indonesia     IDN   Indones… "\U0… MtCO…  1995  1339.    203.  1.98e8 scope1 
 5 Brazil        BRA   Brazil   "\U0… MtCO…  1995  1725.    250.  1.64e8 scope1 
 6 Japan         JPN   Japan    "\U0… MtCO…  1995  1201.   1502.  1.25e8 scope1 
 7 Canada        CAN   Canada   "\U0… MtCO…  1995   646.    409.  2.93e7 scope1 
 8 Saudi Arabia  SAU   Saudi A… "\U0… MtCO…  1995   289.    198   1.89e7 scope1 
 9 Germany       DEU   Germany  "\U0… MtCO…  1995   982.   1072.  8.17e7 scope1 
10 Mexico        MEX   Mexico   "\U0… MtCO…  1995   471.    288   9.00e7 scope1 
# … with 8,198 more rows, 3 more variables: PCAF_em <dbl>, GDP_type <chr>,
#   GDP_measure <dbl>, and abbreviated variable names ¹​country_name,
#   ²​country_ghg_all, ³​total_pop, ⁴​PCAF_scope

Exploratory Data Analysis

Hypothesis 1: Scope Emissions Follow GDP Growth

Show the code
hypothesis1 <- EDA |> 
  filter(GDP_type == "gdp")

hyp1_fit <- lm(GDP_measure ~ PCAF_em, data = hypothesis1)

tidy(hyp1_fit)
# A tibble: 2 × 5
  term             estimate    std.error statistic   p.value
  <chr>               <dbl>        <dbl>     <dbl>     <dbl>
1 (Intercept) 587630410696. 29865999197.      19.7 1.98e- 82
2 PCAF_em        736919899.    19814691.      37.2 3.75e-261
Show the code
#GDP Distribution
ggplot(hypothesis1, aes(x = GDP_measure)) +
    geom_histogram(binwidth = 1000000000000)

Show the code
#PCAF by industry

ggplot(hypothesis1, aes(x = GDP_measure, y = PCAF_em)) +
  geom_bin2d()

Show the code
# install.packages("hexbin")
ggplot(hypothesis1, aes(x = GDP_measure, y = PCAF_em)) +
  geom_hex()

First, we’re looking at the country GDP profiles in our data set which appear highly concentrated in lower GDPs. Two possible adjustments to better view this data are smaller denonminations, the use of GDP per capita, or GNI to classify countries according to WB standards. Lets now look at GDP measured against PCAF scope emissions. Looking across GDP by country and PCAF Scope 1:3 emissions there is a clear trend in GDP growth and higher PCAF emissions. However, its not quite clear what Scope, the magnitude, and by whom. Looking at these trends there appear to be three different trends. Lets break out by scope.

Hypothesis 2: Scope Emission Types Vary by GDP growth

Show the code
EDA |> 
  filter(GDP_type == "gdp") |> 
  ggplot(aes(x = GDP_measure, y = PCAF_em, color = PCAF_scope)) +
    geom_point()

Scope 2 and 3 emissions to be much less depdent on GDP, which is possibly due to the fact that they are import related and possibly better measured by sector-specific capacity within country. Let’s see how Scope Emissions look over time when broken out by type.

Hypothesis 2: Pre-pandemic emissions were increasing across all PCAF scopes

Show the code
#| warning: false

hypothesis2 <- EDA |> 
  group_by(year, PCAF_scope) |> 
  summarise(mean_em = mean(PCAF_em))
`summarise()` has grouped output by 'year'. You can override using the
`.groups` argument.
Show the code
hypothesis2
# A tibble: 72 × 3
# Groups:   year [24]
    year PCAF_scope mean_em
   <dbl> <chr>        <dbl>
 1  1995 scope1      727.  
 2  1995 scope2        1.21
 3  1995 scope3       73.2 
 4  1996 scope1      739.  
 5  1996 scope2        1.4 
 6  1996 scope3       73.0 
 7  1997 scope1      767.  
 8  1997 scope2        1.37
 9  1997 scope3       75.0 
10  1998 scope1      765.  
# … with 62 more rows
Show the code
ggplot(hypothesis2, aes(x = year, y = mean_em, color = PCAF_scope)) +
  geom_line() +
  facet_wrap(~ PCAF_scope, scales = "free_y")

While more current data is needed to see past 2018 and the pandemic recover efforts, these trends still demonstrate increases in scope post Paris Agreement. Interestingly, there is a decline in Scope 2 Emissions dating back to ~2007. Why is that? Further analysis needed on quantiles by countries and policies implemented in respective financial markets.