Final Project Initial Questions

options(repos = c(CRAN = "https://cran.rstudio.com/"))
install.packages("readxl")

The downloaded binary packages are in
    /var/folders/25/scx22j0150v_7hw79jvjm8gh0000gn/T//RtmpT4tSv0/downloaded_packages
install.packages("here")

The downloaded binary packages are in
    /var/folders/25/scx22j0150v_7hw79jvjm8gh0000gn/T//RtmpT4tSv0/downloaded_packages
library(tidyverse) 
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.4.4     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readxl)
library(janitor)

Attaching package: 'janitor'

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

    chisq.test, fisher.test
library(readxl)
library(writexl)
library(here)
here() starts at /Users/palesamnguni/Desktop/Courses/Spring Term/Sustainable Fin
library(lubridate)
library(ggplot2)
library(dplyr)
library(ggplot2)
library(zoo)

Attaching package: 'zoo'

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

    as.Date, as.Date.numeric
library(scales)

Attaching package: 'scales'

The following object is masked from 'package:purrr':

    discard

The following object is masked from 'package:readr':

    col_factor

VIX

#load the data 
library(readxl)
VIXCLS <- read_excel("00_data_raw/VIXCLS.xls", 
   range = "A11:B60")
View(VIXCLS)

Fed Funds Effective Rates

#load the data 
library(readxl)
FEDFUNDS <- read_excel("00_data_raw/FEDFUNDS.xls", 
   range = "A11:B60")
View(FEDFUNDS)

*combining the Fed funds and vix data

econ_indicators <- VIXCLS %>%
  inner_join(FEDFUNDS)
Joining with `by = join_by(observation_date)`
econ_indicators
# A tibble: 49 × 3
   observation_date    VIXCLS FEDFUNDS
   <dttm>               <dbl>    <dbl>
 1 2012-01-01 00:00:00   18.2   0.103 
 2 2012-04-01 00:00:00   20.0   0.153 
 3 2012-07-01 00:00:00   16.2   0.143 
 4 2012-10-01 00:00:00   16.8   0.16  
 5 2013-01-01 00:00:00   13.5   0.143 
 6 2013-04-01 00:00:00   14.8   0.117 
 7 2013-07-01 00:00:00   14.3   0.0833
 8 2013-10-01 00:00:00   14.2   0.0867
 9 2014-01-01 00:00:00   14.8   0.0733
10 2014-04-01 00:00:00   12.7   0.0933
# ℹ 39 more rows

Debt Monitor country set

#loading the data
#1. loading country coverage so I cant later create context about which countries are covered in the dataset 
Sustainable_debt_monitor <- read_excel("00_data_raw/Sustainable_debt_monitor.xlsx", 
    sheet = "Country coverage", range = "A42:D183", 
    col_types = c("skip", "text", "text", 
        "text"))
View(Sustainable_debt_monitor)

Loading the IIF Debt Monitor dataset

here ("00_data_raw", "Sustainable_debt_monitor.xlsx") %>% excel_sheets()
 [1] "Table of contents"               "Country coverage"               
 [3] "1a_global markets - issuance"    "1b_global markets - outstanding"
 [5] "2a_MM by country"                "2b_MM by sector"                
 [7] "3a_EM&FM by country"             "3b_EM&FM by sector"             
 [9] "4a_offshore centers by country"  "4b_offshore centers by sector"  
[11] "5_supranationals by country"     "6_outstanding amt by country "  
[13] "7_Share of ESG debt issuance"   

We’re going to make the data on “1a_global markets - issuance” into a cohesive dataset that we can play around with.

here("00_data_raw", "Sustainable_debt_monitor.xlsx") %>% 
  #specify the sheet + the range of cells in excel
  read_excel(sheet = "1a_global markets - issuance",
             range = "B4:E48") %>%
  # rename the first column to "date"
  rename(date = `$ billion`) %>%
  # Tidy the dataset by making the column names into long format
  pivot_longer(cols = -date, names_to = "geography", values_to = "issuance_bn_usd") %>%
  # coerce the date column into a date object using lubridate::ymd() (year-month_date)
  mutate(date = ymd(date)) %>%
  # Add a column that includes the name of this specific data
  add_column(issuance_type = "Sustainable debt (bonds and loans)")
# A tibble: 132 × 4
   date       geography        issuance_bn_usd issuance_type                    
   <date>     <chr>                      <dbl> <chr>                            
 1 2013-03-31 Mature markets             6.71  Sustainable debt (bonds and loan…
 2 2013-03-31 Emerging markets           1.45  Sustainable debt (bonds and loan…
 3 2013-03-31 Offshore centers           0     Sustainable debt (bonds and loan…
 4 2013-06-30 Mature markets             5.46  Sustainable debt (bonds and loan…
 5 2013-06-30 Emerging markets           0.670 Sustainable debt (bonds and loan…
 6 2013-06-30 Offshore centers           0     Sustainable debt (bonds and loan…
 7 2013-09-30 Mature markets            13.9   Sustainable debt (bonds and loan…
 8 2013-09-30 Emerging markets           1.97  Sustainable debt (bonds and loan…
 9 2013-09-30 Offshore centers           0     Sustainable debt (bonds and loan…
10 2013-12-31 Mature markets            17.7   Sustainable debt (bonds and loan…
# ℹ 122 more rows

There are 11 different sub-datasets on this worksheet, so let’s save ourselves some time and make a function.

process_iif_gb_issuance <- function(range, issuance_type) {
  here("00_data_raw", "Sustainable_debt_monitor.xlsx") %>% 
    read_excel(sheet = "1a_global markets - issuance", range = range) %>%
    rename(date = `$ billion`) %>%
    pivot_longer(cols = -date, names_to = "geography", values_to = "issuance_bn_usd") %>%
    mutate(date = ymd(date)) %>%
    add_column(issuance_type = issuance_type)
}

sustainable debt (bonds and loans)

bonds_and_loans <- process_iif_gb_issuance(range = "B4:G48", 
                                           issuance_type = "Sustainable debt (bonds and loans)")

bonds_and_loans
# A tibble: 220 × 4
   date       geography        issuance_bn_usd issuance_type                    
   <date>     <chr>                      <dbl> <chr>                            
 1 2013-03-31 Mature markets             6.71  Sustainable debt (bonds and loan…
 2 2013-03-31 Emerging markets           1.45  Sustainable debt (bonds and loan…
 3 2013-03-31 Offshore centers           0     Sustainable debt (bonds and loan…
 4 2013-03-31 Supranationals             1.16  Sustainable debt (bonds and loan…
 5 2013-03-31 Global                     9.32  Sustainable debt (bonds and loan…
 6 2013-06-30 Mature markets             5.46  Sustainable debt (bonds and loan…
 7 2013-06-30 Emerging markets           0.670 Sustainable debt (bonds and loan…
 8 2013-06-30 Offshore centers           0     Sustainable debt (bonds and loan…
 9 2013-06-30 Supranationals             0.106 Sustainable debt (bonds and loan…
10 2013-06-30 Global                     6.24  Sustainable debt (bonds and loan…
# ℹ 210 more rows

Bonds

bonds <- process_iif_gb_issuance(range = "I4:N48", 
                                           issuance_type = "Sustainable bonds")

bonds
# A tibble: 220 × 4
   date       geography        issuance_bn_usd issuance_type    
   <date>     <chr>                      <dbl> <chr>            
 1 2013-03-31 Mature markets             1.02  Sustainable bonds
 2 2013-03-31 Emerging markets           0     Sustainable bonds
 3 2013-03-31 Offshore centers           0     Sustainable bonds
 4 2013-03-31 Supranationals             1.16  Sustainable bonds
 5 2013-03-31 Global                     2.18  Sustainable bonds
 6 2013-06-30 Mature markets             1.95  Sustainable bonds
 7 2013-06-30 Emerging markets           0     Sustainable bonds
 8 2013-06-30 Offshore centers           0     Sustainable bonds
 9 2013-06-30 Supranationals             0.106 Sustainable bonds
10 2013-06-30 Global                     2.06  Sustainable bonds
# ℹ 210 more rows

sustainable loans

loans <- process_iif_gb_issuance(range = "P4:U48", 
                                           issuance_type = "Sustainable loans")

loans
# A tibble: 220 × 4
   date       geography        issuance_bn_usd issuance_type    
   <date>     <chr>                      <dbl> <chr>            
 1 2013-03-31 Mature markets             5.68  Sustainable loans
 2 2013-03-31 Emerging markets           1.45  Sustainable loans
 3 2013-03-31 Offshore centers           0     Sustainable loans
 4 2013-03-31 Supranationals             0     Sustainable loans
 5 2013-03-31 Global                     7.13  Sustainable loans
 6 2013-06-30 Mature markets             3.51  Sustainable loans
 7 2013-06-30 Emerging markets           0.670 Sustainable loans
 8 2013-06-30 Offshore centers           0     Sustainable loans
 9 2013-06-30 Supranationals             0     Sustainable loans
10 2013-06-30 Global                     4.18  Sustainable loans
# ℹ 210 more rows

Bind all issuance data

iif_issuance_data <- bonds_and_loans %>%
  bind_rows(loans,bonds)

iif_issuance_data
# A tibble: 660 × 4
   date       geography        issuance_bn_usd issuance_type                    
   <date>     <chr>                      <dbl> <chr>                            
 1 2013-03-31 Mature markets             6.71  Sustainable debt (bonds and loan…
 2 2013-03-31 Emerging markets           1.45  Sustainable debt (bonds and loan…
 3 2013-03-31 Offshore centers           0     Sustainable debt (bonds and loan…
 4 2013-03-31 Supranationals             1.16  Sustainable debt (bonds and loan…
 5 2013-03-31 Global                     9.32  Sustainable debt (bonds and loan…
 6 2013-06-30 Mature markets             5.46  Sustainable debt (bonds and loan…
 7 2013-06-30 Emerging markets           0.670 Sustainable debt (bonds and loan…
 8 2013-06-30 Offshore centers           0     Sustainable debt (bonds and loan…
 9 2013-06-30 Supranationals             0.106 Sustainable debt (bonds and loan…
10 2013-06-30 Global                     6.24  Sustainable debt (bonds and loan…
# ℹ 650 more rows

Issuance by instrument type

green_bonds <- process_iif_gb_issuance(range = "W4:AB48", 
                                           issuance_type = "Green bonds")

green_bonds
# A tibble: 220 × 4
   date       geography        issuance_bn_usd issuance_type
   <date>     <chr>                      <dbl> <chr>        
 1 2013-03-31 Mature markets             0.628 Green bonds  
 2 2013-03-31 Emerging markets           0     Green bonds  
 3 2013-03-31 Offshore centers           0     Green bonds  
 4 2013-03-31 Supranationals             1.02  Green bonds  
 5 2013-03-31 Global                     1.65  Green bonds  
 6 2013-06-30 Mature markets             1.44  Green bonds  
 7 2013-06-30 Emerging markets           0     Green bonds  
 8 2013-06-30 Offshore centers           0     Green bonds  
 9 2013-06-30 Supranationals             0.106 Green bonds  
10 2013-06-30 Global                     1.54  Green bonds  
# ℹ 210 more rows
green_abs <- process_iif_gb_issuance(range = "AD4:AI48", 
                                           issuance_type = "Green ABS")

green_abs
# A tibble: 220 × 4
   date       geography        issuance_bn_usd issuance_type
   <date>     <chr>                      <dbl> <chr>        
 1 2013-03-31 Mature markets                 0 Green ABS    
 2 2013-03-31 Emerging markets               0 Green ABS    
 3 2013-03-31 Offshore centers               0 Green ABS    
 4 2013-03-31 Supranationals                 0 Green ABS    
 5 2013-03-31 Global                         0 Green ABS    
 6 2013-06-30 Mature markets                 0 Green ABS    
 7 2013-06-30 Emerging markets               0 Green ABS    
 8 2013-06-30 Offshore centers               0 Green ABS    
 9 2013-06-30 Supranationals                 0 Green ABS    
10 2013-06-30 Global                         0 Green ABS    
# ℹ 210 more rows

Sustainability bonds

sustainability_bonds <- process_iif_gb_issuance(range = "AK4:AP48", 
                                           issuance_type = "Sustainability bonds")

sustainability_bonds
# A tibble: 220 × 4
   date       geography        issuance_bn_usd issuance_type       
   <date>     <chr>                      <dbl> <chr>               
 1 2013-03-31 Mature markets                 0 Sustainability bonds
 2 2013-03-31 Emerging markets               0 Sustainability bonds
 3 2013-03-31 Offshore centers               0 Sustainability bonds
 4 2013-03-31 Supranationals                 0 Sustainability bonds
 5 2013-03-31 Global                         0 Sustainability bonds
 6 2013-06-30 Mature markets                 0 Sustainability bonds
 7 2013-06-30 Emerging markets               0 Sustainability bonds
 8 2013-06-30 Offshore centers               0 Sustainability bonds
 9 2013-06-30 Supranationals                 0 Sustainability bonds
10 2013-06-30 Global                         0 Sustainability bonds
# ℹ 210 more rows

Social bonds

social_bonds <- process_iif_gb_issuance(range = "AR4:AW48", 
                                           issuance_type = "Social bonds")

social_bonds
# A tibble: 220 × 4
   date       geography        issuance_bn_usd issuance_type
   <date>     <chr>                      <dbl> <chr>        
 1 2013-03-31 Mature markets             0     Social bonds 
 2 2013-03-31 Emerging markets           0     Social bonds 
 3 2013-03-31 Offshore centers           0     Social bonds 
 4 2013-03-31 Supranationals             0.136 Social bonds 
 5 2013-03-31 Global                     0.136 Social bonds 
 6 2013-06-30 Mature markets             0     Social bonds 
 7 2013-06-30 Emerging markets           0     Social bonds 
 8 2013-06-30 Offshore centers           0     Social bonds 
 9 2013-06-30 Supranationals             0     Social bonds 
10 2013-06-30 Global                     0     Social bonds 
# ℹ 210 more rows

Green municipal bonds

green_municipal_bonds <- process_iif_gb_issuance(range = "AY4:BD48", 
                                           issuance_type = "Green municipal bonds")
green_municipal_bonds
# A tibble: 220 × 4
   date       geography        issuance_bn_usd issuance_type        
   <date>     <chr>                      <dbl> <chr>                
 1 2013-03-31 Mature markets             0.396 Green municipal bonds
 2 2013-03-31 Emerging markets           0     Green municipal bonds
 3 2013-03-31 Offshore centers           0     Green municipal bonds
 4 2013-03-31 Supranationals             0     Green municipal bonds
 5 2013-03-31 Global                     0.396 Green municipal bonds
 6 2013-06-30 Mature markets             0.517 Green municipal bonds
 7 2013-06-30 Emerging markets           0     Green municipal bonds
 8 2013-06-30 Offshore centers           0     Green municipal bonds
 9 2013-06-30 Supranationals             0     Green municipal bonds
10 2013-06-30 Global                     0.517 Green municipal bonds
# ℹ 210 more rows

Sustainability linked bonds

sustainability_linked_bonds <- process_iif_gb_issuance(range = "BF4:BK48", 
                                           issuance_type = "Sustainability linked bonds")
sustainability_linked_bonds
# A tibble: 220 × 4
   date       geography        issuance_bn_usd issuance_type              
   <date>     <chr>                      <dbl> <chr>                      
 1 2013-03-31 Mature markets                 0 Sustainability linked bonds
 2 2013-03-31 Emerging markets               0 Sustainability linked bonds
 3 2013-03-31 Offshore centers               0 Sustainability linked bonds
 4 2013-03-31 Supranationals                 0 Sustainability linked bonds
 5 2013-03-31 Global                         0 Sustainability linked bonds
 6 2013-06-30 Mature markets                 0 Sustainability linked bonds
 7 2013-06-30 Emerging markets               0 Sustainability linked bonds
 8 2013-06-30 Offshore centers               0 Sustainability linked bonds
 9 2013-06-30 Supranationals                 0 Sustainability linked bonds
10 2013-06-30 Global                         0 Sustainability linked bonds
# ℹ 210 more rows

Green loans

green_loans <- process_iif_gb_issuance(range = "BM4:BR48", 
                                           issuance_type = "Green loans")
green_loans
# A tibble: 220 × 4
   date       geography        issuance_bn_usd issuance_type
   <date>     <chr>                      <dbl> <chr>        
 1 2013-03-31 Mature markets             3.87  Green loans  
 2 2013-03-31 Emerging markets           0.451 Green loans  
 3 2013-03-31 Offshore centers           0     Green loans  
 4 2013-03-31 Supranationals             0     Green loans  
 5 2013-03-31 Global                     4.32  Green loans  
 6 2013-06-30 Mature markets             1.24  Green loans  
 7 2013-06-30 Emerging markets           0.670 Green loans  
 8 2013-06-30 Offshore centers           0     Green loans  
 9 2013-06-30 Supranationals             0     Green loans  
10 2013-06-30 Global                     1.91  Green loans  
# ℹ 210 more rows

Sustainability linked loans

sustainability_linked_loans <- process_iif_gb_issuance(range = "BT4:BY48", 
                                           issuance_type = "Sustainability linked loans")
sustainability_linked_loans
# A tibble: 220 × 4
   date       geography        issuance_bn_usd issuance_type              
   <date>     <chr>                      <dbl> <chr>                      
 1 2013-03-31 Mature markets              1.82 Sustainability linked loans
 2 2013-03-31 Emerging markets            1    Sustainability linked loans
 3 2013-03-31 Offshore centers            0    Sustainability linked loans
 4 2013-03-31 Supranationals              0    Sustainability linked loans
 5 2013-03-31 Global                      2.82 Sustainability linked loans
 6 2013-06-30 Mature markets              2.27 Sustainability linked loans
 7 2013-06-30 Emerging markets            0    Sustainability linked loans
 8 2013-06-30 Offshore centers            0    Sustainability linked loans
 9 2013-06-30 Supranationals              0    Sustainability linked loans
10 2013-06-30 Global                      2.27 Sustainability linked loans
# ℹ 210 more rows

Binding all the instrument type data and total

iif_issuance_data_type <- bonds_and_loans %>%
  bind_rows(green_bonds, green_abs, sustainability_bonds, social_bonds, green_municipal_bonds, sustainability_linked_bonds, green_loans, sustainability_linked_loans

)

iif_issuance_data_type
# A tibble: 1,980 × 4
   date       geography        issuance_bn_usd issuance_type                    
   <date>     <chr>                      <dbl> <chr>                            
 1 2013-03-31 Mature markets             6.71  Sustainable debt (bonds and loan…
 2 2013-03-31 Emerging markets           1.45  Sustainable debt (bonds and loan…
 3 2013-03-31 Offshore centers           0     Sustainable debt (bonds and loan…
 4 2013-03-31 Supranationals             1.16  Sustainable debt (bonds and loan…
 5 2013-03-31 Global                     9.32  Sustainable debt (bonds and loan…
 6 2013-06-30 Mature markets             5.46  Sustainable debt (bonds and loan…
 7 2013-06-30 Emerging markets           0.670 Sustainable debt (bonds and loan…
 8 2013-06-30 Offshore centers           0     Sustainable debt (bonds and loan…
 9 2013-06-30 Supranationals             0.106 Sustainable debt (bonds and loan…
10 2013-06-30 Global                     6.24  Sustainable debt (bonds and loan…
# ℹ 1,970 more rows

New Function for Emerging Markets (issuance by sector)

process_iif_gb_issuance_sectorEM <- function(range, issuance_type) {
  here("00_data_raw", "Sustainable_debt_monitor.xlsx") %>% 
    read_excel(sheet = "3b_EM&FM by sector", range = range) %>%
    rename(date = `$ billion`) %>%
    pivot_longer(cols = -date, names_to = "sector", values_to = "issuance_bn_usd") %>%
    mutate(date = ymd(date)) %>%
    add_column(issuance_type = issuance_type)
}

**Note all variables ending with _s are sector specific data**

Sustainable bonds and loans

bonds_and_loans_s <- process_iif_gb_issuance_sectorEM (range = "B4:G48",         issuance_type = "Sustainable debt (bonds and loans)")

bonds_and_loans_s
# A tibble: 220 × 4
   date       sector                       issuance_bn_usd issuance_type        
   <date>     <chr>                                  <dbl> <chr>                
 1 2013-03-31 Non-financial corps.                  1.42   Sustainable debt (bo…
 2 2013-03-31 Financial corps.                      0.0297 Sustainable debt (bo…
 3 2013-03-31 Sovereign                             0      Sustainable debt (bo…
 4 2013-03-31 General government (ex-sov.)          0      Sustainable debt (bo…
 5 2013-03-31 ABS                                   0      Sustainable debt (bo…
 6 2013-06-30 Non-financial corps.                  0.670  Sustainable debt (bo…
 7 2013-06-30 Financial corps.                      0      Sustainable debt (bo…
 8 2013-06-30 Sovereign                             0      Sustainable debt (bo…
 9 2013-06-30 General government (ex-sov.)          0      Sustainable debt (bo…
10 2013-06-30 ABS                                   0      Sustainable debt (bo…
# ℹ 210 more rows

Green Bonds

green_bonds_s <- process_iif_gb_issuance_sectorEM(range = "I4:M48", 
                                           issuance_type = "Green bonds")
green_bonds_s
# A tibble: 176 × 4
   date       sector                       issuance_bn_usd issuance_type
   <date>     <chr>                                  <dbl> <chr>        
 1 2013-03-31 Non-financial corps.                       0 Green bonds  
 2 2013-03-31 Financial corps.                           0 Green bonds  
 3 2013-03-31 Sovereign                                  0 Green bonds  
 4 2013-03-31 General government (ex-sov.)               0 Green bonds  
 5 2013-06-30 Non-financial corps.                       0 Green bonds  
 6 2013-06-30 Financial corps.                           0 Green bonds  
 7 2013-06-30 Sovereign                                  0 Green bonds  
 8 2013-06-30 General government (ex-sov.)               0 Green bonds  
 9 2013-09-30 Non-financial corps.                       0 Green bonds  
10 2013-09-30 Financial corps.                           0 Green bonds  
# ℹ 166 more rows

Green ABS

green_abs_s <- process_iif_gb_issuance_sectorEM(range = "O4:P48", 
                                          issuance_type = "Green ABS")
green_abs_s
# A tibble: 44 × 4
   date       sector           issuance_bn_usd issuance_type
   <date>     <chr>                      <dbl> <chr>        
 1 2013-03-31 Emerging markets           0     Green ABS    
 2 2013-06-30 Emerging markets           0     Green ABS    
 3 2013-09-30 Emerging markets           0     Green ABS    
 4 2013-12-31 Emerging markets           0     Green ABS    
 5 2014-03-31 Emerging markets           0     Green ABS    
 6 2014-06-30 Emerging markets           0     Green ABS    
 7 2014-09-30 Emerging markets           0.450 Green ABS    
 8 2014-12-31 Emerging markets           0     Green ABS    
 9 2015-03-31 Emerging markets           0     Green ABS    
10 2015-06-30 Emerging markets           0     Green ABS    
# ℹ 34 more rows

Sustainability bonds

sustainability_bonds_s <- process_iif_gb_issuance_sectorEM(range = "R4:V48", 
                                           issuance_type = "Sustainability bonds")
sustainability_bonds_s
# A tibble: 176 × 4
   date       sector                       issuance_bn_usd issuance_type       
   <date>     <chr>                                  <dbl> <chr>               
 1 2013-03-31 Non-financial corps.                       0 Sustainability bonds
 2 2013-03-31 Financial corps.                           0 Sustainability bonds
 3 2013-03-31 Sovereign                                  0 Sustainability bonds
 4 2013-03-31 General government (ex-sov.)               0 Sustainability bonds
 5 2013-06-30 Non-financial corps.                       0 Sustainability bonds
 6 2013-06-30 Financial corps.                           0 Sustainability bonds
 7 2013-06-30 Sovereign                                  0 Sustainability bonds
 8 2013-06-30 General government (ex-sov.)               0 Sustainability bonds
 9 2013-09-30 Non-financial corps.                       0 Sustainability bonds
10 2013-09-30 Financial corps.                           0 Sustainability bonds
# ℹ 166 more rows

Social Bonds

social_bonds_s<- process_iif_gb_issuance_sectorEM(range = "X4:AB48", 
                                           issuance_type = "Social bonds")

social_bonds_s
# A tibble: 176 × 4
   date       sector                       issuance_bn_usd issuance_type
   <date>     <chr>                                  <dbl> <chr>        
 1 2013-03-31 Non-financial corps.                       0 Social bonds 
 2 2013-03-31 Financial corps.                           0 Social bonds 
 3 2013-03-31 Sovereign                                  0 Social bonds 
 4 2013-03-31 General government (ex-sov.)               0 Social bonds 
 5 2013-06-30 Non-financial corps.                       0 Social bonds 
 6 2013-06-30 Financial corps.                           0 Social bonds 
 7 2013-06-30 Sovereign                                  0 Social bonds 
 8 2013-06-30 General government (ex-sov.)               0 Social bonds 
 9 2013-09-30 Non-financial corps.                       0 Social bonds 
10 2013-09-30 Financial corps.                           0 Social bonds 
# ℹ 166 more rows

Municipal Bonds

green_municipal_bonds_s <- process_iif_gb_issuance_sectorEM(range = "AD4:AH48", 
                                           issuance_type = "Green municipal bonds")
green_municipal_bonds_s
# A tibble: 176 × 4
   date       sector                       issuance_bn_usd issuance_type        
   <date>     <chr>                                  <dbl> <chr>                
 1 2013-03-31 Non-financial corps.                       0 Green municipal bonds
 2 2013-03-31 Financial corps.                           0 Green municipal bonds
 3 2013-03-31 Sovereign                                  0 Green municipal bonds
 4 2013-03-31 General government (ex-sov.)               0 Green municipal bonds
 5 2013-06-30 Non-financial corps.                       0 Green municipal bonds
 6 2013-06-30 Financial corps.                           0 Green municipal bonds
 7 2013-06-30 Sovereign                                  0 Green municipal bonds
 8 2013-06-30 General government (ex-sov.)               0 Green municipal bonds
 9 2013-09-30 Non-financial corps.                       0 Green municipal bonds
10 2013-09-30 Financial corps.                           0 Green municipal bonds
# ℹ 166 more rows

Sustainability-linked bonds

sustainability_linked_bonds_s <- process_iif_gb_issuance_sectorEM(range = "AJ4:AN48", 
                                           issuance_type = "Sustainability linked bonds")

sustainability_linked_bonds_s
# A tibble: 176 × 4
   date       sector                       issuance_bn_usd issuance_type        
   <date>     <chr>                                  <dbl> <chr>                
 1 2013-03-31 Non-financial corps.                       0 Sustainability linke…
 2 2013-03-31 Financial corps.                           0 Sustainability linke…
 3 2013-03-31 Sovereign                                  0 Sustainability linke…
 4 2013-03-31 General government (ex-sov.)               0 Sustainability linke…
 5 2013-06-30 Non-financial corps.                       0 Sustainability linke…
 6 2013-06-30 Financial corps.                           0 Sustainability linke…
 7 2013-06-30 Sovereign                                  0 Sustainability linke…
 8 2013-06-30 General government (ex-sov.)               0 Sustainability linke…
 9 2013-09-30 Non-financial corps.                       0 Sustainability linke…
10 2013-09-30 Financial corps.                           0 Sustainability linke…
# ℹ 166 more rows

Green loans

green_loans_s <- process_iif_gb_issuance_sectorEM(range = "AP4:AT48", 
                                           issuance_type = "Green loans")

green_loans_s
# A tibble: 176 × 4
   date       sector                       issuance_bn_usd issuance_type
   <date>     <chr>                                  <dbl> <chr>        
 1 2013-03-31 Non-financial corps.                  0.421  Green loans  
 2 2013-03-31 Financial corps.                      0.0297 Green loans  
 3 2013-03-31 Sovereign                             0      Green loans  
 4 2013-03-31 General government (ex-sov.)          0      Green loans  
 5 2013-06-30 Non-financial corps.                  0.670  Green loans  
 6 2013-06-30 Financial corps.                      0      Green loans  
 7 2013-06-30 Sovereign                             0      Green loans  
 8 2013-06-30 General government (ex-sov.)          0      Green loans  
 9 2013-09-30 Non-financial corps.                  1.97   Green loans  
10 2013-09-30 Financial corps.                      0      Green loans  
# ℹ 166 more rows

Sustainability-linked loans

sustainability_linked_loans_s <- process_iif_gb_issuance_sectorEM(range = "AV4:AZ48", 
                                           issuance_type = "Sustainability linked loans")

sustainability_linked_loans_s
# A tibble: 176 × 4
   date       sector                       issuance_bn_usd issuance_type        
   <date>     <chr>                                  <dbl> <chr>                
 1 2013-03-31 Non-financial corps.                       1 Sustainability linke…
 2 2013-03-31 Financial corps.                           0 Sustainability linke…
 3 2013-03-31 Sovereign                                  0 Sustainability linke…
 4 2013-03-31 General government (ex-sov.)               0 Sustainability linke…
 5 2013-06-30 Non-financial corps.                       0 Sustainability linke…
 6 2013-06-30 Financial corps.                           0 Sustainability linke…
 7 2013-06-30 Sovereign                                  0 Sustainability linke…
 8 2013-06-30 General government (ex-sov.)               0 Sustainability linke…
 9 2013-09-30 Non-financial corps.                       0 Sustainability linke…
10 2013-09-30 Financial corps.                           0 Sustainability linke…
# ℹ 166 more rows
iif_issuance_data_type_sector_EM <- bonds_and_loans_s %>%
  bind_rows(green_bonds_s, green_abs_s, sustainability_bonds_s, social_bonds_s, green_municipal_bonds_s, sustainability_linked_bonds_s, green_loans_s, sustainability_linked_loans_s)

iif_issuance_data_type_sector_EM
# A tibble: 1,496 × 4
   date       sector                       issuance_bn_usd issuance_type        
   <date>     <chr>                                  <dbl> <chr>                
 1 2013-03-31 Non-financial corps.                  1.42   Sustainable debt (bo…
 2 2013-03-31 Financial corps.                      0.0297 Sustainable debt (bo…
 3 2013-03-31 Sovereign                             0      Sustainable debt (bo…
 4 2013-03-31 General government (ex-sov.)          0      Sustainable debt (bo…
 5 2013-03-31 ABS                                   0      Sustainable debt (bo…
 6 2013-06-30 Non-financial corps.                  0.670  Sustainable debt (bo…
 7 2013-06-30 Financial corps.                      0      Sustainable debt (bo…
 8 2013-06-30 Sovereign                             0      Sustainable debt (bo…
 9 2013-06-30 General government (ex-sov.)          0      Sustainable debt (bo…
10 2013-06-30 ABS                                   0      Sustainable debt (bo…
# ℹ 1,486 more rows

New Function for Mature Markets (issuance by sector)

process_iif_gb_issuance_sectorMM <- function(range, issuance_type) {
  here("00_data_raw", "Sustainable_debt_monitor.xlsx") %>% 
    read_excel(sheet = "2b_MM by sector", range = range) %>%
    rename(date = `$ billion`) %>%
    pivot_longer(cols = -date, names_to = "sector", values_to = "issuance_bn_usd") %>%
    mutate(date = ymd(date)) %>%
    add_column(issuance_type = issuance_type)
}

**Note that _sm is for sectoral level data for mature markets**

Sustainable bonds and loans

bonds_and_loans_sm <- process_iif_gb_issuance_sectorMM (range = "B4:G48",                                           issuance_type = "Sustainable debt (bonds and loans)") 

bonds_and_loans_sm
# A tibble: 220 × 4
   date       sector                       issuance_bn_usd issuance_type        
   <date>     <chr>                                  <dbl> <chr>                
 1 2013-03-31 Non-financial corps.                 5.81    Sustainable debt (bo…
 2 2013-03-31 Financial corps.                     0.00355 Sustainable debt (bo…
 3 2013-03-31 Sovereign                            0       Sustainable debt (bo…
 4 2013-03-31 General government (ex-sov.)         0.897   Sustainable debt (bo…
 5 2013-03-31 ABS                                  0       Sustainable debt (bo…
 6 2013-06-30 Non-financial corps.                 3.70    Sustainable debt (bo…
 7 2013-06-30 Financial corps.                     1.25    Sustainable debt (bo…
 8 2013-06-30 Sovereign                            0       Sustainable debt (bo…
 9 2013-06-30 General government (ex-sov.)         0.517   Sustainable debt (bo…
10 2013-06-30 ABS                                  0       Sustainable debt (bo…
# ℹ 210 more rows

Green Bonds

green_bonds_sm <- process_iif_gb_issuance_sectorMM(range = "I4:M48", 
                                           issuance_type = "Green bonds")
green_bonds_sm
# A tibble: 176 × 4
   date       sector                       issuance_bn_usd issuance_type
   <date>     <chr>                                  <dbl> <chr>        
 1 2013-03-31 Non-financial corps.                 0.124   Green bonds  
 2 2013-03-31 Financial corps.                     0.00355 Green bonds  
 3 2013-03-31 Sovereign                            0       Green bonds  
 4 2013-03-31 General government (ex-sov.)         0.5     Green bonds  
 5 2013-06-30 Non-financial corps.                 1.04    Green bonds  
 6 2013-06-30 Financial corps.                     0.397   Green bonds  
 7 2013-06-30 Sovereign                            0       Green bonds  
 8 2013-06-30 General government (ex-sov.)         0       Green bonds  
 9 2013-09-30 Non-financial corps.                 0.268   Green bonds  
10 2013-09-30 Financial corps.                     0.0563  Green bonds  
# ℹ 166 more rows

Green Bonds

green_bonds_sm <- process_iif_gb_issuance_sectorMM(range = "I4:M48", 
                                           issuance_type = "Green bonds")
green_bonds_sm
# A tibble: 176 × 4
   date       sector                       issuance_bn_usd issuance_type
   <date>     <chr>                                  <dbl> <chr>        
 1 2013-03-31 Non-financial corps.                 0.124   Green bonds  
 2 2013-03-31 Financial corps.                     0.00355 Green bonds  
 3 2013-03-31 Sovereign                            0       Green bonds  
 4 2013-03-31 General government (ex-sov.)         0.5     Green bonds  
 5 2013-06-30 Non-financial corps.                 1.04    Green bonds  
 6 2013-06-30 Financial corps.                     0.397   Green bonds  
 7 2013-06-30 Sovereign                            0       Green bonds  
 8 2013-06-30 General government (ex-sov.)         0       Green bonds  
 9 2013-09-30 Non-financial corps.                 0.268   Green bonds  
10 2013-09-30 Financial corps.                     0.0563  Green bonds  
# ℹ 166 more rows

Green ABS

green_abs_sm <- process_iif_gb_issuance_sectorMM(range = "O4:P48", 
                                          issuance_type = "Green ABS")
green_abs_sm
# A tibble: 44 × 4
   date       sector         issuance_bn_usd issuance_type
   <date>     <chr>                    <dbl> <chr>        
 1 2013-03-31 Mature markets          0      Green ABS    
 2 2013-06-30 Mature markets          0      Green ABS    
 3 2013-09-30 Mature markets          0.239  Green ABS    
 4 2013-12-31 Mature markets          0.161  Green ABS    
 5 2014-03-31 Mature markets          1.87   Green ABS    
 6 2014-06-30 Mature markets          0.377  Green ABS    
 7 2014-09-30 Mature markets          0.213  Green ABS    
 8 2014-12-31 Mature markets          0.28   Green ABS    
 9 2015-03-31 Mature markets          0.0479 Green ABS    
10 2015-06-30 Mature markets          1.51   Green ABS    
# ℹ 34 more rows

Sustainability bonds

sustainability_bonds_sm <- process_iif_gb_issuance_sectorMM(range = "R4:V48", 
                                           issuance_type = "Sustainability bonds") 

sustainability_bonds_sm
# A tibble: 176 × 4
   date       sector                       issuance_bn_usd issuance_type       
   <date>     <chr>                                  <dbl> <chr>               
 1 2013-03-31 Non-financial corps.                       0 Sustainability bonds
 2 2013-03-31 Financial corps.                           0 Sustainability bonds
 3 2013-03-31 Sovereign                                  0 Sustainability bonds
 4 2013-03-31 General government (ex-sov.)               0 Sustainability bonds
 5 2013-06-30 Non-financial corps.                       0 Sustainability bonds
 6 2013-06-30 Financial corps.                           0 Sustainability bonds
 7 2013-06-30 Sovereign                                  0 Sustainability bonds
 8 2013-06-30 General government (ex-sov.)               0 Sustainability bonds
 9 2013-09-30 Non-financial corps.                       0 Sustainability bonds
10 2013-09-30 Financial corps.                           0 Sustainability bonds
# ℹ 166 more rows

Social Bonds

social_bonds_sm<- process_iif_gb_issuance_sectorMM(range = "X4:AB48", 
                                           issuance_type = "Social bonds")

social_bonds_sm
# A tibble: 176 × 4
   date       sector                       issuance_bn_usd issuance_type
   <date>     <chr>                                  <dbl> <chr>        
 1 2013-03-31 Non-financial corps.                       0 Social bonds 
 2 2013-03-31 Financial corps.                           0 Social bonds 
 3 2013-03-31 Sovereign                                  0 Social bonds 
 4 2013-03-31 General government (ex-sov.)               0 Social bonds 
 5 2013-06-30 Non-financial corps.                       0 Social bonds 
 6 2013-06-30 Financial corps.                           0 Social bonds 
 7 2013-06-30 Sovereign                                  0 Social bonds 
 8 2013-06-30 General government (ex-sov.)               0 Social bonds 
 9 2013-09-30 Non-financial corps.                       0 Social bonds 
10 2013-09-30 Financial corps.                           0 Social bonds 
# ℹ 166 more rows

Green municipal Bonds

green_municipal_bonds_sm <- process_iif_gb_issuance_sectorMM(range = "AD4:AH48", 
                                           issuance_type = "Green municipal bonds")
green_municipal_bonds_sm
# A tibble: 176 × 4
   date       sector                       issuance_bn_usd issuance_type        
   <date>     <chr>                                  <dbl> <chr>                
 1 2013-03-31 Non-financial corps.                   0     Green municipal bonds
 2 2013-03-31 Financial corps.                       0     Green municipal bonds
 3 2013-03-31 Sovereign                              0     Green municipal bonds
 4 2013-03-31 General government (ex-sov.)           0.396 Green municipal bonds
 5 2013-06-30 Non-financial corps.                   0     Green municipal bonds
 6 2013-06-30 Financial corps.                       0     Green municipal bonds
 7 2013-06-30 Sovereign                              0     Green municipal bonds
 8 2013-06-30 General government (ex-sov.)           0.517 Green municipal bonds
 9 2013-09-30 Non-financial corps.                   0     Green municipal bonds
10 2013-09-30 Financial corps.                       0     Green municipal bonds
# ℹ 166 more rows

Sustainability-linked bonds

sustainability_linked_bonds_sm <- process_iif_gb_issuance_sectorMM(range = "AJ4:AN48", 
                                           issuance_type = "Sustainability linked bonds")

sustainability_linked_bonds_sm
# A tibble: 176 × 4
   date       sector                       issuance_bn_usd issuance_type        
   <date>     <chr>                                  <dbl> <chr>                
 1 2013-03-31 Non-financial corps.                       0 Sustainability linke…
 2 2013-03-31 Financial corps.                           0 Sustainability linke…
 3 2013-03-31 Sovereign                                  0 Sustainability linke…
 4 2013-03-31 General government (ex-sov.)               0 Sustainability linke…
 5 2013-06-30 Non-financial corps.                       0 Sustainability linke…
 6 2013-06-30 Financial corps.                           0 Sustainability linke…
 7 2013-06-30 Sovereign                                  0 Sustainability linke…
 8 2013-06-30 General government (ex-sov.)               0 Sustainability linke…
 9 2013-09-30 Non-financial corps.                       0 Sustainability linke…
10 2013-09-30 Financial corps.                           0 Sustainability linke…
# ℹ 166 more rows

Green loans

green_loans_sm <- process_iif_gb_issuance_sectorMM(range = "AP4:AT48", 
                                           issuance_type = "Green loans")

green_loans_sm
# A tibble: 176 × 4
   date       sector                       issuance_bn_usd issuance_type
   <date>     <chr>                                  <dbl> <chr>        
 1 2013-03-31 Non-financial corps.                  3.87   Green loans  
 2 2013-03-31 Financial corps.                      0      Green loans  
 3 2013-03-31 Sovereign                             0      Green loans  
 4 2013-03-31 General government (ex-sov.)          0      Green loans  
 5 2013-06-30 Non-financial corps.                  1.16   Green loans  
 6 2013-06-30 Financial corps.                      0.0785 Green loans  
 7 2013-06-30 Sovereign                             0      Green loans  
 8 2013-06-30 General government (ex-sov.)          0      Green loans  
 9 2013-09-30 Non-financial corps.                  0.972  Green loans  
10 2013-09-30 Financial corps.                      0      Green loans  
# ℹ 166 more rows

Sustainability-linked loans

sustainability_linked_loans_sm <- process_iif_gb_issuance_sectorMM(range = "AV4:AZ48", 
                                           issuance_type = "Sustainability linked loans")

sustainability_linked_loans_sm
# A tibble: 176 × 4
   date       sector                       issuance_bn_usd issuance_type        
   <date>     <chr>                                  <dbl> <chr>                
 1 2013-03-31 Non-financial corps.                   1.82  Sustainability linke…
 2 2013-03-31 Financial corps.                       0     Sustainability linke…
 3 2013-03-31 Sovereign                              0     Sustainability linke…
 4 2013-03-31 General government (ex-sov.)           0     Sustainability linke…
 5 2013-06-30 Non-financial corps.                   1.50  Sustainability linke…
 6 2013-06-30 Financial corps.                       0.774 Sustainability linke…
 7 2013-06-30 Sovereign                              0     Sustainability linke…
 8 2013-06-30 General government (ex-sov.)           0     Sustainability linke…
 9 2013-09-30 Non-financial corps.                   6.55  Sustainability linke…
10 2013-09-30 Financial corps.                       4.54  Sustainability linke…
# ℹ 166 more rows

Binding the sector-level data for mature markets

iif_issuance_data_type_sector_MM <- bonds_and_loans_sm %>%
  bind_rows(green_bonds_sm, green_abs_sm, sustainability_bonds_sm, social_bonds_sm, green_municipal_bonds_sm, sustainability_linked_bonds_sm, green_loans_sm, sustainability_linked_loans_sm)

iif_issuance_data_type_sector_MM
# A tibble: 1,496 × 4
   date       sector                       issuance_bn_usd issuance_type        
   <date>     <chr>                                  <dbl> <chr>                
 1 2013-03-31 Non-financial corps.                 5.81    Sustainable debt (bo…
 2 2013-03-31 Financial corps.                     0.00355 Sustainable debt (bo…
 3 2013-03-31 Sovereign                            0       Sustainable debt (bo…
 4 2013-03-31 General government (ex-sov.)         0.897   Sustainable debt (bo…
 5 2013-03-31 ABS                                  0       Sustainable debt (bo…
 6 2013-06-30 Non-financial corps.                 3.70    Sustainable debt (bo…
 7 2013-06-30 Financial corps.                     1.25    Sustainable debt (bo…
 8 2013-06-30 Sovereign                            0       Sustainable debt (bo…
 9 2013-06-30 General government (ex-sov.)         0.517   Sustainable debt (bo…
10 2013-06-30 ABS                                  0       Sustainable debt (bo…
# ℹ 1,486 more rows

Writing out all the created datasets I will be needing into cvs files

write.csv(econ_indicators, "econindicators.csv")
write.csv(Sustainable_debt_monitor, "countrylist.csv")
write.csv(iif_issuance_data, "totalissuance.csv")
write.csv(iif_issuance_data_type, "issuancetype.csv")
write.csv(iif_issuance_data_type_sector_EM, "sectorissuanceEM.csv")
write.csv(iif_issuance_data_type_sector_MM, "sectorissuanceMM.csv")

Loading the data

library(readr)
econindicators <- read_csv("econindicators.csv")
New names:
Rows: 49 Columns: 4
── Column specification
──────────────────────────────────────────────────────── Delimiter: "," dbl
(3): ...1, VIXCLS, FEDFUNDS date (1): observation_date
ℹ 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.
• `` -> `...1`
View(econindicators)

library(readr)
totalissuance <- read_csv("totalissuance.csv")
New names:
Rows: 660 Columns: 5
── Column specification
──────────────────────────────────────────────────────── Delimiter: "," chr
(2): geography, issuance_type dbl (2): ...1, issuance_bn_usd date (1): date
ℹ 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.
• `` -> `...1`
View(totalissuance)

library(readr)
countrylist <- read_csv("countrylist.csv")
New names:
Rows: 141 Columns: 4
── Column specification
──────────────────────────────────────────────────────── Delimiter: "," chr
(3): Emerging and frontier markets (141), Mature markets (35), Offshore ... dbl
(1): ...1
ℹ 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.
• `` -> `...1`
View(countrylist)

library(readr)
issuancetype <- read_csv("issuancetype.csv")
New names:
Rows: 1980 Columns: 5
── Column specification
──────────────────────────────────────────────────────── Delimiter: "," chr
(2): geography, issuance_type dbl (2): ...1, issuance_bn_usd date (1): date
ℹ 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.
• `` -> `...1`
View(issuancetype)

library(readr)
sectorissuanceEM <- read_csv("sectorissuanceEM.csv")
New names:
Rows: 1496 Columns: 5
── Column specification
──────────────────────────────────────────────────────── Delimiter: "," chr
(2): sector, issuance_type dbl (2): ...1, issuance_bn_usd date (1): date
ℹ 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.
• `` -> `...1`
View(sectorissuanceEM)

library(readr)
sectorissuanceMM <- read_csv("sectorissuanceMM.csv")
New names:
Rows: 1496 Columns: 5
── Column specification
──────────────────────────────────────────────────────── Delimiter: "," chr
(2): sector, issuance_type dbl (2): ...1, issuance_bn_usd date (1): date
ℹ 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.
• `` -> `...1`
View(sectorissuanceMM)

Fixing issuance macro data

totalissuance
# A tibble: 660 × 5
    ...1 date       geography        issuance_bn_usd issuance_type              
   <dbl> <date>     <chr>                      <dbl> <chr>                      
 1     1 2013-03-31 Mature markets             6.71  Sustainable debt (bonds an…
 2     2 2013-03-31 Emerging markets           1.45  Sustainable debt (bonds an…
 3     3 2013-03-31 Offshore centers           0     Sustainable debt (bonds an…
 4     4 2013-03-31 Supranationals             1.16  Sustainable debt (bonds an…
 5     5 2013-03-31 Global                     9.32  Sustainable debt (bonds an…
 6     6 2013-06-30 Mature markets             5.46  Sustainable debt (bonds an…
 7     7 2013-06-30 Emerging markets           0.670 Sustainable debt (bonds an…
 8     8 2013-06-30 Offshore centers           0     Sustainable debt (bonds an…
 9     9 2013-06-30 Supranationals             0.106 Sustainable debt (bonds an…
10    10 2013-06-30 Global                     6.24  Sustainable debt (bonds an…
# ℹ 650 more rows
library(dplyr)

totalissuance <- totalissuance %>% 
  slice(-1)
totalissuance
# A tibble: 659 × 5
    ...1 date       geography        issuance_bn_usd issuance_type              
   <dbl> <date>     <chr>                      <dbl> <chr>                      
 1     2 2013-03-31 Emerging markets           1.45  Sustainable debt (bonds an…
 2     3 2013-03-31 Offshore centers           0     Sustainable debt (bonds an…
 3     4 2013-03-31 Supranationals             1.16  Sustainable debt (bonds an…
 4     5 2013-03-31 Global                     9.32  Sustainable debt (bonds an…
 5     6 2013-06-30 Mature markets             5.46  Sustainable debt (bonds an…
 6     7 2013-06-30 Emerging markets           0.670 Sustainable debt (bonds an…
 7     8 2013-06-30 Offshore centers           0     Sustainable debt (bonds an…
 8     9 2013-06-30 Supranationals             0.106 Sustainable debt (bonds an…
 9    10 2013-06-30 Global                     6.24  Sustainable debt (bonds an…
10    11 2013-09-30 Mature markets            13.9   Sustainable debt (bonds an…
# ℹ 649 more rows

Charting aggregate data

headline_issuance <- totalissuance |> 
                     filter(issuance_type == "Sustainable debt (bonds and loans)")

headline_issuance
# A tibble: 219 × 5
    ...1 date       geography        issuance_bn_usd issuance_type              
   <dbl> <date>     <chr>                      <dbl> <chr>                      
 1     2 2013-03-31 Emerging markets           1.45  Sustainable debt (bonds an…
 2     3 2013-03-31 Offshore centers           0     Sustainable debt (bonds an…
 3     4 2013-03-31 Supranationals             1.16  Sustainable debt (bonds an…
 4     5 2013-03-31 Global                     9.32  Sustainable debt (bonds an…
 5     6 2013-06-30 Mature markets             5.46  Sustainable debt (bonds an…
 6     7 2013-06-30 Emerging markets           0.670 Sustainable debt (bonds an…
 7     8 2013-06-30 Offshore centers           0     Sustainable debt (bonds an…
 8     9 2013-06-30 Supranationals             0.106 Sustainable debt (bonds an…
 9    10 2013-06-30 Global                     6.24  Sustainable debt (bonds an…
10    11 2013-09-30 Mature markets            13.9   Sustainable debt (bonds an…
# ℹ 209 more rows
#plotting issuance_bn_usd over time for different geographies using the correct dataframe
ggplot(headline_issuance, aes(x = date, y = issuance_bn_usd, color = geography)) +
  geom_line() +
  theme_minimal() +
  labs(title = "Sustainable Debt Issuance over Time",
       x = "Date",
       y = "Issuance (Billion USD)",
       color = "Geography") +
  scale_x_date(date_breaks = "1 year", date_labels = "%Y")  

Fixing the table so I can calculate issuances as a share of global issuance

# First, obtain the total global issuance for each date.
global_totals <- headline_issuance %>%
  filter(geography == "Global") %>%
  rename(global_issuance = issuance_bn_usd) %>%
  select(date, global_issuance)

# Make sure that 'data' is indeed a dataframe or a tibble.
# Now, join this with the original data to have the global issuance amounts alongside each entry.
data_with_global <- headline_issuance %>%
  left_join(global_totals, by = "date")

# Finally, calculate the share for each geography as a percentage of the global total.
data_with_shares <- data_with_global %>%
  mutate(share_of_global = (issuance_bn_usd / global_issuance) * 100)

# View the result
print(data_with_shares)
# A tibble: 219 × 7
    ...1 date       geography      issuance_bn_usd issuance_type global_issuance
   <dbl> <date>     <chr>                    <dbl> <chr>                   <dbl>
 1     2 2013-03-31 Emerging mark…           1.45  Sustainable …            9.32
 2     3 2013-03-31 Offshore cent…           0     Sustainable …            9.32
 3     4 2013-03-31 Supranationals           1.16  Sustainable …            9.32
 4     5 2013-03-31 Global                   9.32  Sustainable …            9.32
 5     6 2013-06-30 Mature markets           5.46  Sustainable …            6.24
 6     7 2013-06-30 Emerging mark…           0.670 Sustainable …            6.24
 7     8 2013-06-30 Offshore cent…           0     Sustainable …            6.24
 8     9 2013-06-30 Supranationals           0.106 Sustainable …            6.24
 9    10 2013-06-30 Global                   6.24  Sustainable …            6.24
10    11 2013-09-30 Mature markets          13.9   Sustainable …           21.0 
# ℹ 209 more rows
# ℹ 1 more variable: share_of_global <dbl>

Charting the shares data

# Filter out the 'Global' geography
data_without_global <- data_with_shares %>%
  filter(geography != "Global")

# Now plot the data without 'Global'
ggplot(data_without_global, aes(x = date, y = share_of_global, color = geography, group = geography)) +
  geom_smooth() +
  labs(title = "Share of Global Issuance by Geography Over Time",
       x = "Date",
       y = "Share of Global (%)",
       color = "Geography") +
  theme_minimal() +
  scale_x_date(date_breaks = "1 year", date_labels = "%Y")  # Adjust date_breaks and date_labels as needed
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'

Alternative plot

ggplot(data_without_global, aes(x = date, y = share_of_global, group = geography)) +
  geom_line() +
  facet_wrap(~ geography, scales = 'free_y') + # This will create separate panels for each geography
  labs(title = "Share of Global Issuance by Geography Over Time",
       x = "Date",
       y = "Share of Global (%)") +
  theme_minimal() +
  theme(strip.text.x = element_text(size = 8)) # This will ensure the facet labels are not too large

Alternative graph

library(plotly)

Attaching package: 'plotly'
The following object is masked from 'package:ggplot2':

    last_plot
The following object is masked from 'package:stats':

    filter
The following object is masked from 'package:graphics':

    layout
fig <- data_without_global %>%
  plot_ly(x = ~date, y = ~share_of_global, color = ~geography, type = 'scatter', mode = 'lines')

fig <- fig %>%
  layout(title = "Share of Global Issuance by Geography Over Time",
         xaxis = list(title = "Date"),
         yaxis = list(title = "Share of Global (%)"))

fig