library(readr)
read_csv("/Users/xingyuning/Desktop/susfin/final project/01_data_cleaning/comparison.csv")
## Rows: 664 Columns: 27
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (14): link, handle, ISIN, CUSIP, FIGI, ticker, bond_name, issuer_name, ...
## dbl (11): issuance_year, volume_usd_billion, volume_usd, volume_bond_curren...
## lgl (1): fund
## date (1): issuance_date.y
##
## ℹ 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.
read_csv("/Users/xingyuning/Desktop/susfin/final project/01_data_cleaning/bonds_new.csv")
## Rows: 160 Columns: 20
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (15): link, handle, ISIN, CUSIP, FIGI, ticker, bond_name, issuer_name, i...
## dbl (4): issuance_year, volume_usd_billion, volume_usd, volume_bond_currency
## lgl (1): fund
##
## ℹ 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.
read_csv("/Users/xingyuning/Desktop/susfin/final project/01_data_cleaning/allocations_new.csv")
## Rows: 2278 Columns: 17
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (11): bond_handle, bond_name, nomenclature, category, subcategory, proje...
## dbl (5): allocated_allocation_currency, disbursed_allocation_currency, disb...
## lgl (1): refinancing
##
## ℹ 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.
Question1: What is the trend of the issuance of green bonds in LAC?
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ purrr 1.0.2
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ── 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(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
library(ggplot2)
library(scales)
##
## Attaching package: 'scales'
##
## The following object is masked from 'package:purrr':
##
## discard
##
## The following object is masked from 'package:readr':
##
## col_factor
comparison <- read_csv("/Users/xingyuning/Desktop/susfin/final project/01_data_cleaning/comparison.csv")
## Rows: 664 Columns: 27
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (14): link, handle, ISIN, CUSIP, FIGI, ticker, bond_name, issuer_name, ...
## dbl (11): issuance_year, volume_usd_billion, volume_usd, volume_bond_curren...
## lgl (1): fund
## date (1): issuance_date.y
##
## ℹ 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.
data_long_comparison <- comparison |>
pivot_longer(cols = c("LAC_volume_usd", "global_volume_usd"), names_to = "volume_type", values_to = "issuance_volume")
# Plot the data
p <- ggplot(data_long_comparison, aes(x = issuance_year, y = issuance_volume, color = volume_type)) +
geom_line() +
geom_point() +
scale_color_manual(values = c("LAC_volume_usd" = "#377eb8", "global_volume_usd" = "#4daf4a")) +
theme_minimal() +
labs(title = "The trend of Issuance of Green Bonds", x = "Year", y = "Issuance Volume (bn)", color = "Volume Type")
ggplotly(p)
Question2: What is the Yearly Green Bond Issuance Growth: Latin America vs. Global
library(dplyr)
data_growth <- comparison %>%
arrange(issuance_year) %>%
mutate(
LAC_growth = (LAC_volume_usd - lag(LAC_volume_usd)) / lag(LAC_volume_usd) * 100,
Global_growth = (global_volume_usd - lag(global_volume_usd)) / lag(global_volume_usd) * 100
)
print(data_growth)
## # A tibble: 664 × 29
## link handle ISIN CUSIP FIGI ticker bond_name issuer_name issuer_type
## <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 https://ww… fe8a8… MX90… AM35… BBG0… 90_GC… GCDMXCB … Gobierno d… Local gove…
## 2 https://ww… fe8a8… MX90… AM35… BBG0… 90_GC… GCDMXCB … Gobierno d… Local gove…
## 3 https://ww… fe8a8… MX90… AM35… BBG0… 90_GC… GCDMXCB … Gobierno d… Local gove…
## 4 https://ww… fe8a8… MX90… AM35… BBG0… 90_GC… GCDMXCB … Gobierno d… Local gove…
## 5 https://ww… ee7a6… US05… 0567… <NA> <NA> Suzano P… Suzano Pap… Non-Financ…
## 6 https://ww… ee7a6… US05… 0567… <NA> <NA> Suzano P… Suzano Pap… Non-Financ…
## 7 https://ww… ee7a6… US05… 0567… <NA> <NA> Suzano P… Suzano Pap… Non-Financ…
## 8 https://ww… ee7a6… US05… 0567… <NA> <NA> Suzano P… Suzano Pap… Non-Financ…
## 9 https://ww… 0f91b… USP1… JK87… <NA> <NA> Banco Na… Banco Naci… Developmen…
## 10 https://ww… 0f91b… USP1… JK87… <NA> <NA> Banco Na… Banco Naci… Developmen…
## # ℹ 654 more rows
## # ℹ 20 more variables: issuer_jurisdiction <chr>, fund <lgl>,
## # framework_link <chr>, issuance_year <dbl>, issuance_date.x <chr>,
## # maturity_date <chr>, volume_usd_billion <dbl>, volume_usd <dbl>,
## # volume_bond_currency <dbl>, bond_currency <chr>, LAC_volume_usd <dbl>,
## # issuance_date.y <date>, `Mature markets` <dbl>, `Emerging markets` <dbl>,
## # `Offshore centers` <dbl>, Supranationals <dbl>, Global <dbl>, …
library(tidyr)
library(ggplot2)
data_growth_long <- data_growth %>%
pivot_longer(cols = c("LAC_growth", "Global_growth"), names_to = "growth_type", values_to = "growth_rate")
p_growth <- ggplot(data_growth_long, aes(x = issuance_year, y = growth_rate, color = growth_type)) +
geom_line() +
geom_point() +
scale_color_viridis_d(begin = 0.3, end = 0.9, option = "D") +
theme_minimal() +
labs(title = "Annual Growth Rate of Green Bond Issuance", x = "Year", y = "Growth Rate (%)", color = "Growth Type")
ggplotly(p_growth)
library(leaflet)
library(countrycode)
library(rnaturalearth)
bonds_new <- read_csv("/Users/xingyuning/Desktop/susfin/final project/01_data_cleaning/bonds_new.csv")
## Rows: 160 Columns: 20
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (15): link, handle, ISIN, CUSIP, FIGI, ticker, bond_name, issuer_name, i...
## dbl (4): issuance_year, volume_usd_billion, volume_usd, volume_bond_currency
## lgl (1): fund
##
## ℹ 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.
bonds_new$issuer_jurisdiction <- ifelse(bonds_new$issuer_jurisdiction == "Supranational", NA, bonds_new$issuer_jurisdiction)
bonds_new$ISO_code <- countrycode(bonds_new$issuer_jurisdiction, origin = "country.name", destination = "iso3c", warn = FALSE)
bonds_new <- bonds_new[!is.na(bonds_new$ISO_code), ]
# Calculate the total volume issued by ISO code
bonds_summary <- bonds_new %>%
group_by(ISO_code) %>%
summarise(volume_usd_total = sum(volume_usd, na.rm = TRUE))
# Get the world map and filter for Latin America and the Caribbean
world_map <- ne_countries(scale = "medium", returnclass = "sf")
latin_america_caribbean_map <- world_map[world_map$region_un == "Americas" &
world_map$subregion %in% c("Central America", "South America", "Caribbean"), ]
# Merge the map data with the summary data
latin_america_bonds <- merge(latin_america_caribbean_map, bonds_summary, by.x = "iso_a3", by.y = "ISO_code")
# Create an interactive map using leaflet
leaflet(latin_america_bonds) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
addPolygons(fillColor = ~colorQuantile("Blues", volume_usd_total)(volume_usd_total),
color = "#BDBDC3",
weight = 1,
opacity = 1,
fillOpacity = 0.7,
highlight = highlightOptions(weight = 2,
color = "#666",
fillOpacity = 0.7),
label = ~paste(iso_a3, ":", formatC(volume_usd_total, format = "f", big.mark = ","))) %>%
addLegend("bottomright", pal = colorQuantile("Blues", latin_america_bonds$volume_usd_total),
values = ~volume_usd_total,
title = "Issuance Volume (USD)",
labFormat = labelFormat(big.mark = ","))
Question3: How is the allocation of green bonds in Latin America?
library(dplyr)
library(ggplot2)
allocations_new <- read_csv("/Users/xingyuning/Desktop/susfin/final project/01_data_cleaning/allocations_new.csv")
## Rows: 2278 Columns: 17
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (11): bond_handle, bond_name, nomenclature, category, subcategory, proje...
## dbl (5): allocated_allocation_currency, disbursed_allocation_currency, disb...
## lgl (1): refinancing
##
## ℹ 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.
distinct_allocations <- allocations_new %>%
distinct(bond_name, .keep_all = TRUE)
allocation_counts <- distinct_allocations %>%
group_by(category) %>%
summarise(count = n())
allocation_counts <- allocation_counts %>%
mutate(percentage = count / sum(count) * 100)
library(plotly)
fig <- plot_ly(allocation_counts, labels = ~category, values = ~percentage, type = 'pie', textinfo = 'label+percent',
insidetextorientation = 'radial') %>%
layout(title = 'Proportion of Green Bond Allocation By issuance Number')
fig
library(dplyr)
library(plotly)
allocation_sums <- distinct_allocations %>%
group_by(category) %>%
summarise(total_amount = sum(disbursed_usd))
allocation_sums <- allocation_sums %>%
mutate(percentage_amount = total_amount / sum(total_amount) * 100)
allocation_counts <- distinct_allocations %>%
group_by(category) %>%
summarise(count = n())
allocation_counts <- allocation_counts %>%
mutate(percentage_count = count / sum(count) * 100)
fig <- subplot(
plot_ly(allocation_counts, labels = ~category, values = ~percentage_count, name = 'Count', type = 'pie', textinfo = 'label+percent', insidetextorientation = 'radial') %>%
layout(title = 'Proportion of Green Bond Allocation by Count'),
plot_ly(allocation_sums, labels = ~category, values = ~percentage_amount, name = 'Amount', type = 'pie', textinfo = 'label+percent', insidetextorientation = 'radial') %>%
layout(title = 'Proportion of Green Bond Allocation by Amount')
)
fig
## Warning: 'layout' objects don't have these attributes: 'NA'
## Valid attributes include:
## '_deprecated', 'activeshape', 'annotations', 'autosize', 'autotypenumbers', 'calendar', 'clickmode', 'coloraxis', 'colorscale', 'colorway', 'computed', 'datarevision', 'dragmode', 'editrevision', 'editType', 'font', 'geo', 'grid', 'height', 'hidesources', 'hoverdistance', 'hoverlabel', 'hovermode', 'images', 'legend', 'mapbox', 'margin', 'meta', 'metasrc', 'modebar', 'newshape', 'paper_bgcolor', 'plot_bgcolor', 'polar', 'scene', 'selectdirection', 'selectionrevision', 'separators', 'shapes', 'showlegend', 'sliders', 'smith', 'spikedistance', 'template', 'ternary', 'title', 'transition', 'uirevision', 'uniformtext', 'updatemenus', 'width', 'xaxis', 'yaxis', 'barmode', 'bargap', 'mapType'
library(dplyr)
library(plotly)
allocation_sums <- distinct_allocations %>%
group_by(category) %>%
summarise(total_amount = sum(disbursed_usd))
allocation_sums <- allocation_sums %>%
mutate(percentage_amount = total_amount / sum(total_amount) * 100)
allocation_counts <- distinct_allocations %>%
group_by(category) %>%
summarise(count = n())
allocation_counts <- allocation_counts %>%
mutate(percentage_count = count / sum(count) * 100)
fig <- subplot(
plot_ly(allocation_counts, labels = ~category, values = ~percentage_count, name = 'Count', type = 'pie', textinfo = 'label+percent', insidetextorientation = 'radial') %>%
layout(title = 'Proportion of Green Bond Allocation by Count'),
plot_ly(allocation_sums, labels = ~category, values = ~percentage_amount, name = 'Amount', type = 'pie', textinfo = 'label+percent', insidetextorientation = 'radial') %>%
layout(title = 'Proportion of Green Bond Allocation by Amount')
)
fig
## Warning: 'layout' objects don't have these attributes: 'NA'
## Valid attributes include:
## '_deprecated', 'activeshape', 'annotations', 'autosize', 'autotypenumbers', 'calendar', 'clickmode', 'coloraxis', 'colorscale', 'colorway', 'computed', 'datarevision', 'dragmode', 'editrevision', 'editType', 'font', 'geo', 'grid', 'height', 'hidesources', 'hoverdistance', 'hoverlabel', 'hovermode', 'images', 'legend', 'mapbox', 'margin', 'meta', 'metasrc', 'modebar', 'newshape', 'paper_bgcolor', 'plot_bgcolor', 'polar', 'scene', 'selectdirection', 'selectionrevision', 'separators', 'shapes', 'showlegend', 'sliders', 'smith', 'spikedistance', 'template', 'ternary', 'title', 'transition', 'uirevision', 'uniformtext', 'updatemenus', 'width', 'xaxis', 'yaxis', 'barmode', 'bargap', 'mapType'
Question4: Issuer type
library(dplyr)
library(plotly)
bonds_new_issuer <- bonds_new %>%
distinct(bond_name, .keep_all = TRUE)
issuer_counts <- bonds_new_issuer %>%
group_by(issuer_type) %>%
summarise(count = n())
# Calculate the percentage on the correct data frame
issuer_counts <- issuer_counts %>%
mutate(percentage = count / sum(count) * 100)
# Create the pie chart with plotly
fig <- plot_ly(issuer_counts, labels = ~issuer_type, values = ~percentage, type = 'pie', textinfo = 'label+percent',
insidetextorientation = 'radial') %>%
layout(title = 'Proportion of Issuer Type of Green Bonds in LAC')
# Display the figure
fig