── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.1 ✔ readr 2.1.4
✔ forcats 1.0.0 ✔ stringr 1.5.0
✔ ggplot2 3.4.1 ✔ tibble 3.2.1
✔ lubridate 1.9.2 ✔ tidyr 1.3.0
✔ purrr 1.0.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(janitor)
Attaching package: 'janitor'
The following objects are masked from 'package:stats':
chisq.test, fisher.test
install.packages("countrycode")
Installing package into 'C:/Users/alyss/AppData/Local/R/win-library/4.2'
(as 'lib' is unspecified)
package 'countrycode' successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\alyss\AppData\Local\Temp\Rtmp6bD4AZ\downloaded_packages
Rows: 355 Columns: 42
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (12): Country, ISO2, ISO3, Indicator, Unit, Source, CTS_Code, CTS_Name, ...
dbl (30): ObjectId, F1985, F1986, F1987, F1990, F1991, F1992, F1993, F1994, ...
ℹ 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.
# bring in green debt subset indicators_we_want <-c("Green Bond Issuances by Country", "Sovereign Green Bond Issuances")green_debt_subset <- green_debt |>clean_names() |>filter(indicator %in% indicators_we_want) |>select(country, iso3, indicator, matches("f\\d{4}")) green_debt_subset |>pivot_longer(cols =matches("f\\d{4}") )
# A tibble: 3,103 × 5
country iso3 indicator name value
<chr> <chr> <chr> <chr> <dbl>
1 Argentina ARG Green Bond Issuances by Country f1985 NA
2 Argentina ARG Green Bond Issuances by Country f1986 NA
3 Argentina ARG Green Bond Issuances by Country f1987 NA
4 Argentina ARG Green Bond Issuances by Country f1990 NA
5 Argentina ARG Green Bond Issuances by Country f1991 NA
6 Argentina ARG Green Bond Issuances by Country f1992 NA
7 Argentina ARG Green Bond Issuances by Country f1993 NA
8 Argentina ARG Green Bond Issuances by Country f1994 NA
9 Argentina ARG Green Bond Issuances by Country f1999 NA
10 Argentina ARG Green Bond Issuances by Country f2000 NA
# ℹ 3,093 more rows
# adding region from countrycode package green_debt_region <- green_debt_subset %>%mutate(region =countrycode(iso3, "iso3c", "un.region.name"))
Warning: There was 1 warning in `mutate()`.
ℹ In argument: `region = countrycode(iso3, "iso3c", "un.region.name")`.
Caused by warning:
! Some values were not matched unambiguously: TWN
green_bonds_tidy <- green_debt_region |>pivot_longer(cols =matches("f\\d{4}"),names_to ="year",values_to ="issuance_bn_usd",names_transform = readr::parse_number,values_drop_na =TRUE )# calculating cumulative issuance per regiongreen_bonds_tidy_cumulative <- green_bonds_tidy |>arrange(region, year) |>group_by(region, indicator) |>mutate(cumulative_bn_usd =cumsum(issuance_bn_usd)) |>ungroup()biggest_green_bond_issuers <- green_bonds_tidy_cumulative |>filter(indicator =="Green Bond Issuances by Country") |>group_by(region) |>slice_max(order_by = year) |>arrange(cumulative_bn_usd|>desc()) |>select(region, cumulative_bn_usd)# creating graphbiggest_green_bond_issuers %>%filter(!is.na(region)) %>%ggplot() +aes(x = region, weight = cumulative_bn_usd) +geom_bar(fill ="#4682B4") +labs(x ="Region", y ="Cumulative Issuance (USD)", title ="Cumulative Bond Issuance by Region", caption ="Data: IMF Climate Change Dashboard | Insight: Alyssa Anderson") +theme_minimal()+scale_y_continuous(labels = scales::label_dollar(suffix =" bn"),expand =c(0,0))
Rows: 355 Columns: 42
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (12): Country, ISO2, ISO3, Indicator, Unit, Source, CTS_Code, CTS_Name, ...
dbl (30): ObjectId, F1985, F1986, F1987, F1990, F1991, F1992, F1993, F1994, ...
ℹ 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.
# filtering out N/A issuer type, and creating snake case namesgreen_debt_clean_names <- green_debt |>clean_names() |>filter(type_of_issuer !="Not Applicable")# creating graphggplot(green_debt_clean_names) +aes(x = type_of_issuer, y = f2022) +geom_col(fill ="#A92DEF") +labs(x ="Type of Issuer",y ="Green Bond Issuance (USD)",title ="Green Bond Issuances in 2022 by Issuer",subtitle ="Banks and Nonfinancial Corporations had the largest green bond issuances in 2022",caption ="Data: IMF Climate Change Dashboard | Insight: Alyssa Anderson")+theme_minimal()+theme(axis.text.x =element_text(angle =45, hjust =1))+scale_y_continuous(labels = scales::label_dollar(suffix =" bn"),expand =c(0,0))
# state and local governments only issued 1% of green bonds in 2022!!factoid_1 <- green_debt_clean_names |>mutate(bond_f22_pct = f2022/sum(f2022) *100)
Question 3:
Green Bond Proceeds are used for a variety of purposes, with the highest amount of bond issuances in 2022 going toward eco-friendly technology and clean transportation.
The majority of green bonds in 2022 were denominated in the Euro, and before 2022, the currency was not applicable, so we cannot tell if the principal currency has changed over time.
Rows: 355 Columns: 42
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (12): Country, ISO2, ISO3, Indicator, Unit, Source, CTS_Code, CTS_Name, ...
dbl (30): ObjectId, F1985, F1986, F1987, F1990, F1991, F1992, F1993, F1994, ...
ℹ 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.
# filtering out N/A use of proceeds, and creating snake case namesgreen_debt_proceed <- green_debt |>clean_names() |>filter(use_of_proceed !="Not Applicable")ggplot(green_debt_proceed) +aes(x = use_of_proceed, y = f2022) +geom_col(fill ="#228B22") +labs(x ="Use of Proceed",y ="Green Bond Issuance (USD)",title ="Use of Green Bond Proceeds in 2022",subtitle ="The majority of proceeds are used for Eco-Efficient Technology and Clean Transportation",caption ="Data: IMF Climate Change Dashboard | Insight: Alyssa Anderson")+theme_minimal()+theme(axis.text.x =element_text(size =5, angle =90, hjust =1))
# filtering out N/A principal currency, and creating snake case namesgreen_debt_currency <- green_debt |>clean_names() |>filter(principal_currency !="Not Applicable")ggplot(green_debt_currency) +aes(x = f2022, y = principal_currency) +geom_violin(adjust =1L, scale ="area", fill ="#B22222") +labs(x ="Green Bond Issuance (USD)",y ="Principal Currency",title ="Principal Currency in 2022",subtitle ="The majority of green bonds are denominated in the Euro",caption ="Data: IMF Climate Change Dashboard | Insight: Alyssa Anderson")+theme_minimal()+theme(axis.text.y =element_text(size =5))