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

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

iif_issuance_data <- bonds_and_loans %>%
  bind_rows(bonds)

iif_issuance_data
## # A tibble: 370 × 4
##    date       geography        issuance_bn_usd issuance_type                    
##    <date>     <chr>                      <dbl> <chr>                            
##  1 2013-03-31 Mature markets             6.19  Sustainable debt (bonds and loan…
##  2 2013-03-31 Emerging markets           0.451 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                     7.80  Sustainable debt (bonds and loan…
##  6 2013-06-30 Mature markets             4.08  Sustainable debt (bonds and loan…
##  7 2013-06-30 Emerging markets           0.595 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                     4.78  Sustainable debt (bonds and loan…
## # … with 360 more rows
loans <- process_iif_gb_issuance(range = "P4:U41", 
                                           issuance_type = "Sustainable loans")

iif_issuance_data <- iif_issuance_data %>%
  bind_rows(loans)

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

iif_issuance_data <- iif_issuance_data %>%
  bind_rows(green_bonds)

green_abs <- process_iif_gb_issuance(range = "AD4:AI41", 
                                           issuance_type = "Green ABS")

iif_issuance_data <- iif_issuance_data %>%
  bind_rows(green_abs)

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

iif_issuance_data <- iif_issuance_data %>%
  bind_rows(sustainability_bonds)

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

iif_issuance_data <- iif_issuance_data %>%
  bind_rows(social_bonds)

green_municipal_bonds <- process_iif_gb_issuance(range = "AY4:BD41", 
                                           issuance_type = "Green municipal bonds")

iif_issuance_data <- iif_issuance_data %>%
  bind_rows(green_municipal_bonds)

sustainability_linked_bonds <- process_iif_gb_issuance(range = "BF4:BK41", 
                                           issuance_type = "Sustainability-linked bonds")

iif_issuance_data <- iif_issuance_data %>%
  bind_rows(sustainability_linked_bonds)

green_loans <- process_iif_gb_issuance(range = "BM4:BR41", 
                                           issuance_type = "Green loans")

iif_issuance_data <- iif_issuance_data %>%
  bind_rows(green_loans)

sustainability_linked_loans <- process_iif_gb_issuance(range = "BT4:BY41", 
                                           issuance_type = "Sustainability-linked loans")

iif_issuance_data <- iif_issuance_data %>%
  bind_rows(sustainability_linked_loans)

iif_issuance_data
## # A tibble: 2,035 × 4
##    date       geography        issuance_bn_usd issuance_type                    
##    <date>     <chr>                      <dbl> <chr>                            
##  1 2013-03-31 Mature markets             6.19  Sustainable debt (bonds and loan…
##  2 2013-03-31 Emerging markets           0.451 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                     7.80  Sustainable debt (bonds and loan…
##  6 2013-06-30 Mature markets             4.08  Sustainable debt (bonds and loan…
##  7 2013-06-30 Emerging markets           0.595 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                     4.78  Sustainable debt (bonds and loan…
## # … with 2,025 more rows
iif_issuance_data %>%
  mutate(year = lubridate::year(date))%>%
  filter(geography == c("Mature markets","Emerging markets")) %>%
  group_by(year, geography, issuance_type) %>%
  summarize(total = sum(issuance_bn_usd)) %>%
  ggplot(aes(x = year, y = total)) + 
  geom_line(aes(color = issuance_type)) +
    labs(title = 'Trend',
         subtitle = "in Emerging and Mature Markets",
         x = "Time", 
         y = "Issuance in USD [Bn]") +
  theme_minimal()+
  facet_grid(geography ~.)
## Warning in geography == c("Mature markets", "Emerging markets"): longer object
## length is not a multiple of shorter object length
## `summarise()` has grouped output by 'year', 'geography'. You can override using
## the `.groups` argument.

iif_issuance_data %>%
  filter(issuance_type == "Sustainability-linked loans" | issuance_type == "Green loans" | issuance_type == "Sustainable loans" & date >= ymd("2020-03-31")) %>%
  group_by(geography) %>%
  ggplot(aes(x = geography, y = issuance_bn_usd, fill = issuance_type)) +
  geom_col(position = "dodge") +
  labs(title = 'Loan Issuance by Geography, recent 3 years',
       x = "Geography", 
       y = "Total [Bn]",
       caption = "Source: IIF") +
  theme(axis.text.x = element_text(angle = 90, vjust = 0 , hjust = 1))

issuance_pre_pandemic <- iif_issuance_data %>%
  filter(geography == c("Emerging markets","Mature markets")
         & date <= ymd("2020-03-01"))
## Warning in geography == c("Emerging markets", "Mature markets"): longer object
## length is not a multiple of shorter object length
treemap(issuance_pre_pandemic, 
        index = c("geography","issuance_type"), 
        vSize = "issuance_bn_usd",
        fontsize.labels=c(12,8),
        fontcolor.labels=c("blue","black"),
        fontface.labels=c(2,1),
        align.labels=list(c("left", "top"), c("center", "center")),
        overlap.labels=0.5,
        inflate.labels=F,
        palette = "Blues",
        title = "Issuance type: Comparison between emerging and mature markets"
        )