Task 1: Use world bank data to analyze something

library(wbstats)   
str(wb_cachelist, max.level = 1) # Finding available data
## List of 8
##  $ countries    : tibble [304 × 18] (S3: tbl_df/tbl/data.frame)
##  $ indicators   : tibble [16,649 × 8] (S3: tbl_df/tbl/data.frame)
##  $ sources      : tibble [63 × 9] (S3: tbl_df/tbl/data.frame)
##  $ topics       : tibble [21 × 3] (S3: tbl_df/tbl/data.frame)
##  $ regions      : tibble [48 × 4] (S3: tbl_df/tbl/data.frame)
##  $ income_levels: tibble [7 × 3] (S3: tbl_df/tbl/data.frame)
##  $ lending_types: tibble [4 × 3] (S3: tbl_df/tbl/data.frame)
##  $ languages    : tibble [23 × 3] (S3: tbl_df/tbl/data.frame)
wbsearch("gdp growth")
##                indicatorID                                       indicator
## 676         5.51.01.10.gdp                           Per capita GDP growth
## 679         6.0.GDP_growth                           GDP growth (annual %)
## 7128            GFDD.OI.19 Banking crisis dummy (1=banking crisis, 0=none)
## 9961        NV.AGR.TOTL.ZG          Real agricultural GDP growth rates (%)
## 10162    NY.GDP.MKTP.KD.ZG                           GDP growth (annual %)
## 10165 NY.GDP.MKTP.KN.87.ZG                           GDP growth (annual %)
#choose NY.GDP.MKTP.KD.ZG
library(wbstats)
library(ggplot2)
library(dplyr)
library(sf)

# Get gross domestic product per capita data for all countries from 1960 to 2022
gdp <- wb(country = "all", indicator = "NY.GDP.MKTP.KD.ZG", startdate = 2016, enddate = 2022)

# world country polygons 'medium' scale 
world_geo <- rnaturalearth::ne_countries(scale = 50, returnclass = "sf")
  
gdp_geo <- left_join(world_geo, gdp, by = c("iso_a2" = "iso2c"))

library(ggplot2)
library(viridis)
library(gridExtra)

year <- seq(min(gdp$date),max(gdp$date))

map <- list()

for (i in year) {
p <- ggplot(subset(gdp_geo,date == i)) +
    geom_sf(aes(fill = value)) +
    scale_fill_viridis("value") +
    labs(title = paste("Annual GDP Growth in", i))

 t <- which(year == i)
 # add the plot to the list
  map[[t]]<- p
}  
grid.arrange(grobs = map)

From the GDP growth rate map between 2018 and 2020, it is evident that the COVID-19 pandemic had a significant impact on the global economy. The map clearly shows that the GDP growth rate suffered a substantial decrease during this period, as a result of the pandemic’s widespread impact on various sectors. However, the economy appears to have started its recovery from the year 2021.