Let’s use the wbstats
package for R
:
Search for indicators
https://data.worldbank.org/indicator
indicatorID <chr> | ||
---|---|---|
35 | WP15177.9 | |
36 | WP15177.8 | |
37 | WP15177.7 | |
38 | WP15177.6 | |
39 | WP15177.5 | |
40 | WP15177.4 | |
41 | WP15177.3 | |
42 | WP15177.2 | |
43 | WP15177.10 | |
44 | WP15177.1 |
Figure out what country code is in World Bank (e.g. “US” for United States)
usa<-wb(country = c("US"),
indicator = c("NY.GDP.PCAP.CD", "NY.GDP.PCAP.KD.ZG", "SL.UEM.TOTL.ZS", "FP.CPI.TOTL.ZG", "GC.DOD.TOTL.GD.ZS", "SP.POP.TOTL", "SP.POP.GROW", "SI.POV.GINI", "SP.DYN.LE00.IN", "SP.DYN.IMRT.IN", "SI.POV.DDAY", "NE.TRD.GNFS.ZS"),
startdate = 1970, enddate = 2019,
return_wide = TRUE) %>%
mutate(date = as.numeric(date)) %>%
rename("Year" = date,
"GDP_per_Capita"= NY.GDP.PCAP.CD,
"GDP_growth" = NY.GDP.PCAP.KD.ZG,
"Unemployment" = SL.UEM.TOTL.ZS,
"Inflation" = FP.CPI.TOTL.ZG,
"Debt_pct_GDP" = GC.DOD.TOTL.GD.ZS,
"Population" = SP.POP.TOTL,
"Pop_growth" = SP.POP.GROW,
"Gini" = SI.POV.GINI,
"Life_Exp" = SP.DYN.LE00.IN,
"Infant_mortality" = SP.DYN.IMRT.IN,
"Poverty_pct" = SI.POV.DDAY,
"Trade_pct_GDP" = NE.TRD.GNFS.ZS)
iso3c <chr> | Year <dbl> | iso2c <chr> | country <chr> | Inflation <dbl> | Debt_pct_GDP <dbl> | Trade_pct_GDP <dbl> | GDP_per_Capita <dbl> | |
---|---|---|---|---|---|---|---|---|
USA | 1970 | US | United States | 5.8382553 | NA | 10.75829 | 5234.297 | |
USA | 1971 | US | United States | 4.2927667 | NA | 10.75718 | 5609.383 | |
USA | 1972 | US | United States | 3.2722782 | NA | 11.34062 | 6094.018 | |
USA | 1973 | US | United States | 6.1777601 | NA | 13.07929 | 6726.359 | |
USA | 1974 | US | United States | 11.0548048 | NA | 16.44499 | 7225.691 | |
USA | 1975 | US | United States | 9.1431469 | NA | 15.51637 | 7801.457 | |
USA | 1976 | US | United States | 5.7448126 | NA | 16.04885 | 8592.254 | |
USA | 1977 | US | United States | 6.5016840 | NA | 16.41789 | 9452.577 | |
USA | 1978 | US | United States | 7.6309638 | NA | 16.97283 | 10564.948 | |
USA | 1979 | US | United States | 11.2544711 | NA | 18.37619 | 11674.186 |
ggplot(data = usa)+
aes(x = Year,
y = GDP_per_Capita)+
#geom_point()+
geom_path(size=2, color = "blue")+
scale_x_continuous(breaks=seq(1970,2020,10))+
scale_y_continuous(breaks=seq(10000,60000,10000),
labels=scales::dollar)+
theme_classic(base_family = "Fira Sans Condensed", base_size=18)+
labs(x = "Year",
y = "GDP per Capita (Current USD)")
## Warning: Removed 1 rows containing missing values (geom_path).
ggplot(data = usa)+
aes(x = Year,
y = Unemployment)+
#geom_point()+
geom_path(size=2, color = "blue")+
scale_x_continuous(breaks=seq(1970,2020,10))+
scale_y_continuous(labels=function(x){paste(x,"%")})+
theme_classic(base_family = "Fira Sans Condensed", base_size=18)+
labs(x = "Year",
y = "Unemployment Rate (%)")
## Warning: Removed 21 rows containing missing values (geom_path).
ggplot(data = usa)+
aes(x = Year,
y = GDP_growth)+
#geom_point()+
geom_path(size=2, color = "blue")+
geom_hline(yintercept=0, size =1)+
scale_x_continuous(breaks=seq(1970,2020,10))+
scale_y_continuous(labels=function(x){paste(x,"%")})+
theme_classic(base_family = "Fira Sans Condensed", base_size=18)+
labs(x = "Year",
y = "GDP per Capita Growth")
## Warning: Removed 1 rows containing missing values (geom_path).