Getting World Bank Data

Here, I use the WDI package to import data on per capita income and government education spending for the year 2016 from the World Bank’s World Development Indicators data set. The goal is to create scatter diagrams that shed light on the link between affluence and government spending on education and highlight one country, India.

library(tidyverse)
library(WDI)
mydata <- WDI(indicator = c("NY.GDP.PCAP.CD", "NY.GDP.PCAP.PP.CD", "SE.XPD.TOTL.GD.ZS", "SE.XPD.TOTL.GB.ZS"), start = 2016, end = 2016, extra = FALSE)
mydata2 <- rename(mydata, 
                  c(GDP.per.capita.current.international.dollars = NY.GDP.PCAP.CD,
                    GDP.per.capita.PPP.current.international.dollars = NY.GDP.PCAP.PP.CD,
                    Government.expenditure.on.education.percent.GDP = SE.XPD.TOTL.GD.ZS,
                    Government.expenditure.on.education.percent.government.expenditure = SE.XPD.TOTL.GB.ZS
                    ))

Figure 1

# Figure 1
ggplot(mydata2, mapping = aes(x = GDP.per.capita.current.international.dollars, y = Government.expenditure.on.education.percent.GDP)) +
  geom_point() + 
  geom_smooth(method = "lm", se = FALSE) + 
  labs(
    y = "Government expenditure on education (% of GDP)",
    x = "GDP per capita (current international $)"
  ) +
  annotate("text", x = mydata2[mydata2$country == "India", ]$GDP.per.capita.current.international.dollars, y = mydata2[mydata2$country == "India", ]$Government.expenditure.on.education.percent.GDP, label = "India") +
  scale_x_continuous(trans = 'log2')

India data in Figure 1: Income is 1732.55 dollars and education spending is 3.45 percent.

Figure 2

# Figure 2
ggplot(mydata2, mapping = aes(x = GDP.per.capita.current.international.dollars, y = Government.expenditure.on.education.percent.government.expenditure)) +
  geom_point() + 
  geom_smooth(method = "lm", se = FALSE) + 
  labs(
    y = "Government expenditure on education (% of government expenditure)",
    x = "GDP per capita (current international $)"
  ) +
  annotate("text", x = mydata2[mydata2$country == "India", ]$GDP.per.capita.current.international.dollars, y = mydata2[mydata2$country == "India", ]$Government.expenditure.on.education.percent.government.expenditure, label = "India") +
  scale_x_continuous(trans = 'log2')

India data in Figure 2: Income is 1732.55 dollars and education spending is 12.75 percent.

Figure 3

# Figure 3
ggplot(mydata2, mapping = aes(x = GDP.per.capita.PPP.current.international.dollars, y = Government.expenditure.on.education.percent.GDP)) +
  geom_point() + 
  geom_smooth(method = "lm", se = FALSE) + 
  labs(
    y = "Government expenditure on education (% of GDP)",
    x = "GDP per capita (current PPP international $)"
  ) +
  annotate("text", x = mydata2[mydata2$country == "India", ]$GDP.per.capita.PPP.current.international.dollars, y = mydata2[mydata2$country == "India", ]$Government.expenditure.on.education.percent.GDP, label = "India")  +
  scale_x_continuous(trans = 'log2')

India data in Figure 3: Income is 5839.86 dollars and education spending is 3.45 percent.

Figure 4

# Figure 2
ggplot(mydata2, mapping = aes(x = GDP.per.capita.PPP.current.international.dollars, y = Government.expenditure.on.education.percent.government.expenditure)) +
  geom_point() + 
  geom_smooth(method = "lm", se = FALSE) + 
  labs(
    y = "Government expenditure on education (% of government expenditure)",
    x = "GDP per capita (current PPP international $)"
  ) +
  annotate("text", x = mydata2[mydata2$country == "India", ]$GDP.per.capita.PPP.current.international.dollars, y = mydata2[mydata2$country == "India", ]$Government.expenditure.on.education.percent.government.expenditure, label = "India")  +
  scale_x_continuous(trans = 'log2')

India data in Figure 4: Income is 5839.86 dollars and education spending is 12.75 percent.

Conclusion

All four figures show that India’s government spending on education – either as a percentage of per capita GDP or as a percentage of overall government spending – is less than what India’s per capita GDP would lead one to expect. India is below the line of best fit in all four charts.

R Techniques Used

The End