Skip to content

Instantly share code, notes, and snippets.

@chrissyhroberts
Last active January 19, 2018 12:06
Show Gist options
  • Save chrissyhroberts/68dd4e42298d69af77a388aa3475a9bc to your computer and use it in GitHub Desktop.
Save chrissyhroberts/68dd4e42298d69af77a388aa3475a9bc to your computer and use it in GitHub Desktop.
World map colour by country name
library(rworldmap)
theCountries<-read.table("Countries.txt",header=T,sep="\t")
# These are the ISO3 names of the countries you'd like to plot in red
malMap <- joinCountryData2Map(theCountries, joinCode = "ISO3",
nameJoinColumn = "ISO.ALPHA.3.Code")
# This will join your malDF data.frame to the country map data
summary(factor(theCountries$ODK.project))
mapCountryData(malMap, nameColumnToPlot="ODK.project", catMethod = "categorical",
missingCountryCol = gray(.8),addLegend = F,borderCol = T,mapTitle = NULL)
# And this will plot it, with the trick that the color palette's first
# color is red
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment