Now, we download the worldbank data and subset it so that it will include GINI coefficients only for 2005 and 2013. Because the GINI coefficient for 2005 for India is missing, the idea of the previous chunk was to scrape the urban and rural GINI coefficients for India and compute the weighted GINI coefficient and replace the NA for 2005 for India with that value.

library(RCurl)
## Warning: package 'RCurl' was built under R version 3.2.4
## Loading required package: bitops
worlddata = subset(read.csv(text = getURL("https://raw.githubusercontent.com/cyadusha/Popular-indicators/master/55e42714-cbf5-42ee-9995-eed3fc8d3102_Data.csv"), sep = ","), select = c(Country.Name, X1981..YR1981., X2013..YR2013.))
colnames(worlddata)[1] = "Country Name"
colnames(worlddata)[2] = "1981GINI"
colnames(worlddata)[3] = "2013GINI"
worlddata = worlddata[1:214,]
worlddata$`1981GINI` = as.numeric(as.vector(worlddata$`1981GINI`))
## Warning: NAs introduced by coercion
worlddata$`2013GINI` = as.numeric(as.vector(worlddata$`2013GINI`))
## Warning: NAs introduced by coercion
worlddata$`1981GINI` = as.vector(worlddata$`1981GINI`/100)
worlddata$`2013GINI` = as.vector(worlddata$`2013GINI`/100)

Now, we load the worldmap package and plot the map of the entire world and color each country according to its GINI coefficient.

library(rworldmap)
## Warning: package 'rworldmap' was built under R version 3.2.3
## Loading required package: sp
## Warning: package 'sp' was built under R version 3.2.3
## ### Welcome to rworldmap ###
## For a short introduction type :   vignette('rworldmap')
library(graphics)
n = joinCountryData2Map(worlddata, joinCode="NAME", nameJoinColumn="Country Name")
## 207 codes from your data successfully matched countries in the map
## 7 codes from your data failed to match with a country code in the map
## 36 codes from the map weren't represented in your data
par(mfrow=c(2,1))
plot1 = mapCountryData(n, nameColumnToPlot="1981GINI", mapTitle = "1981", addLegend = F)
do.call(addMapLegend, c(plot1, legendLabels="all", legendIntervals="data", legendMar = 2 ))
plot2 = mapCountryData(n, nameColumnToPlot="2013GINI", mapTitle = "2013", addLegend = F)
do.call(addMapLegend, c(plot1, legendLabels="all", legendIntervals="data", legendMar = 2 ))