library(writexl)Warning: package 'writexl' was built under R version 4.3.3
library(countrycode)Warning: package 'countrycode' was built under R version 4.3.3
library(tidyverse)Warning: package 'tidyverse' was built under R version 4.3.3
Warning: package 'ggplot2' was built under R version 4.3.3
Warning: package 'tibble' was built under R version 4.3.3
Warning: package 'tidyr' was built under R version 4.3.3
Warning: package 'readr' was built under R version 4.3.3
Warning: package 'purrr' was built under R version 4.3.3
Warning: package 'dplyr' was built under R version 4.3.3
Warning: package 'stringr' was built under R version 4.3.3
Warning: package 'forcats' was built under R version 4.3.3
Warning: package 'lubridate' was built under R version 4.3.3
── 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.5.0 ✔ 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(janitor)
Attaching package: 'janitor'
The following objects are masked from 'package:stats':
chisq.test, fisher.test
library(countrycode)
library(ggplot2)
library(hrbrthemes)Warning: package 'hrbrthemes' was built under R version 4.3.3
library(viridis)Loading required package: viridisLite
Warning: package 'viridisLite' was built under R version 4.3.3
library(readxl)Warning: package 'readxl' was built under R version 4.3.3
library(here)here() starts at C:/Users/owner/Desktop/Sustainable Finance/Final paper/Final paper
all_hands_bloomberg <- read_csv("C:/Users/owner/Desktop/Sustainable Finance/R/climate_finance_needs.csv")Rows: 196 Columns: 25
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (7): country_name, iso3c, region_name, sub_region_name, annex_1, report...
dbl (18): least_developed_countries_ldc, land_locked_developing_countries_ll...
ℹ 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.
top_countries <- all_hands_bloomberg %>%
group_by(country_name) %>%
summarise(total = sum(total)) %>%
arrange(desc(total)) %>%
top_n(10)Selecting by total
other_countries <- all_hands_bloomberg %>%
filter(!country_name %in% top_countries$country_name) %>%
summarise(total = sum(total, na.rm = TRUE)) %>%
mutate(country_name = "Others combined")
# Combine top countries and other countries data
combined_data <- bind_rows(top_countries, other_countries)
combined_data$country_name <- factor(
combined_data$country_name,
levels = c(top_countries$country_name, "Others combined")
)
chart1 <- combined_data |>
ggplot(aes(x=country_name, y=total)) +
geom_bar(stat="identity") +
geom_col() +
theme(legend.position = "",legend.title = element_blank())+
scale_y_continuous(labels = scales::label_dollar(suffix = " BN")) +
labs(
x="",
y="Expressed climate financing needs",
caption="Data compiled from national reports submitted to the UNFCCC")+
xlab("")
chart1