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.
# we want to compare these two indicatorsindicators_we_want <-c("Green Bond Issuances by Country", "Sovereign Green Bond Issuances")green_debt_subset <- green_debt |># from the janitor package -- makes variables snake_case so they are easier to work withclean_names() |># filter for the vector of indicators we defined abovefilter(indicator %in% indicators_we_want) |># "f\\d{4}" is a regular expression (regex) that searches for all columns that are f + four digits.# Ask ChatGPT to explain this to you.select(country, iso3, indicator, matches("f\\d{4}")) green_debt_subset <- green_debt |>mutate(region =countrycode(Country, "country.name", "region"))
Warning: There was 1 warning in `mutate()`.
ℹ In argument: `region = countrycode(Country, "country.name", "region")`.
Caused by warning:
! Some values were not matched unambiguously: World
green_tidy <- green_debt_subset %>%pivot_longer(cols =matches("f\\d{4}"),names_to ="year",values_to ="issuance_bn_usd",names_transform = readr::parse_number,values_drop_na =TRUE )cumulative_issuance <- green_tidy %>%group_by(region) %>%mutate(cumulative_issuance =cumsum(issuance_bn_usd),na.rm =TRUE)%>%arrange(desc(issuance_bn_usd))cumulative_issuance_clean <-na.omit(cumulative_issuance)ggplot(cumulative_issuance_clean, aes(x =reorder(region, cumulative_issuance), y = issuance_bn_usd, fill = region)) +geom_bar(stat ="identity") +labs(x ="Region", y ="Cumulative Issuance", fill ="Region") +ggtitle("Cumulative Issuance of Green Bonds by Region") +scale_y_continuous (labels = scales::label_dollar(suffix =" bn",prefix ="$", scale =1))+theme_minimal()+coord_flip()
`summarise()` has grouped output by 'type_of_issuer'. You can override using
the `.groups` argument.
green_tidy %>%ggplot(aes(x = year, y = total_issuance_bn_usd, fill = type_of_issuer)) +geom_col() +scale_x_continuous(limits =c(2012, 2022)) +scale_y_continuous(labels = scales::label_dollar(suffix =" bn")) +labs(title ="Total Green Bond Issuance by Type of Issuer", x ="Year", y ="Total Issuance (USD in billion)") +theme_minimal() +theme(legend.position ="bottom")
# A tibble: 50 × 2
principal_currency count
<chr> <int>
1 Argentinian Peso 2
2 Argentinian Unidades de Valor Adquisitivo 2
3 Australian Dollar 2
4 Bangladeshi Taka 2
5 Brazilian Real 2
6 British Pound 2
7 Canadian Dollar 2
8 Chilean Peso 2
9 Chilean Unidad de Fomento 2
10 Chinese Yuan 2
# ℹ 40 more rows
We can see that each currency has appeared twice in the dataset, all of them are in 2022.