As expected population drift is from less developed to more
developed regions.
Here is the R code for this-
#Required Library- fastest way to draw this chart is through
‘rworldmap’ package
library(rworldmap)
#Load Data- it loads data in R environment
migrantsData <- read.csv("Migrants_data.csv")
#Join data to map- this step essentially attaches location (Long\
Lat) for each country
spdf <-
joinCountryData2Map(migrantsData,joinCode="UN",
nameJoinColumn="Country.code",nameCountryColumn=
"Country",verbose = TRUE)
#Draw world map- required function to draw this map is ‘mapCountryData’.
For more details on this, #please refer - ‘http://cran.r-project.org/web/packages/rworldmap/rworldmap.pdf’
par(mai=c(0,0,0.2,0),xaxs="i",yaxs="i")
mapParams <- mapCountryData( spdf,
nameColumnToPlot="Migrants", addLegend=FALSE,numCats=7,colourPalette="terrain",
mapTitle="Net Number of Migrants (Immigrants - Emigrants), 2005-2010
(Thousands)", oceanCol="lightblue")
do.call( addMapLegend, c(mapParams, legendWidth=0.5,
legendMar = 4,legendLabels="all"))
And that’s it! Similar code can be used for any other metric.
Thanks, for now!
No comments:
Post a Comment