Homework 9- APIs

Duflo’s Plumber Economist

2023-02-14

#Loading required packages (might not end up using all of the loaded ones)
library(prettydoc) #For the theme used in this document
library(reshape2) #Required for reshaping the data
library(dplyr)
library(wbstats)
library(ggplot2)
library(gtrendsR)

Task 1: Use world bank data to analyze something

#Setting up the directory
setwd("D:/UGA Coursework/Second Year/AAEC 8610/HWs/HW9")
getwd()
## [1] "D:/UGA Coursework/Second Year/AAEC 8610/HWs/HW9"
# Load required libraries
library(wbstats)
library(ggplot2)

# Defininf the countries
countries <- c("BAN", "IND", "PAK", "LKA", "MDV", "NPL")

# Downloading the data from World Bank for an indicator
df <- wb(indicator = "FB.CBK.BRCH.P5", country = countries, startdate = 2000, enddate = 2021)

graph <- ggplot(df, aes(x=date, y=value, colour=country)) + 
 geom_point(size = 2, alpha = 0.8) +
  labs(title = "Commercial bank branches (per 100,000 adults)", 
        y="Commercial bank branches (per 100,000 adults)", x="Year") +
  theme_classic()
graph

In the graph above, I plot the number of commercial bank branches per million adults for six South Asian nations. Access to financial institutions is considered as one of the major determinants of development. The plot shows that in 2004, Nepal had the lowest number of commercial banks per million adults. However, over the time, the number increased steeply for Nepal compared to other countries. On the other hand, the number is stagnant for Pakistan.