Bangladesh geofacet plot: Female population projections by upazilas

BGD_plot

Bangladesh 2020 population pyramids by upazila

BGD_pyr.png

Population Pyramids of Georgia in ggplot2

You can download session 9 files for constructing the population pyramids of Georgia here: RLadies Tbilisi 

rm(list=ls(all=TRUE))
cat("\014")
mypath <- "/Users/GozerTheGozerian/Keymasters Folder/"
setwd(paste(mypath)) #set your working directory
##  [1] "Index"
##  [2] "Variant"
##  [3] "Major.area..region..country.or.area.."
##  [4] "sex"
##  [5] "Notes"
##  [6] "Country.code"
##  [7] "Reference.date..as.of.1.July."
##  [8] "X0.4"
##  [9] "X05.Sep"
## [10] "Oct.14"
## [11] "X15.19"
[...]
## [23] "X75.79"
## [24] "X80."
## [25] "X80.84"
## [26] "X85.89"
## [27] "X90.94"
## [28] "X95.99"
## [29] "X100."
head(pyr)
##   Index   Variant Major.area..region..country.or.area..  sex Notes
## 1     1 Estimates                                 WORLD both
## 2     2 Estimates                                 WORLD both
## 3     3 Estimates                                 WORLD both
## 4     4 Estimates                                 WORLD both
## 5     5 Estimates                                 WORLD both
## 6     6 Estimates                                 WORLD both
##   Country.code Reference.date..as.of.1.July.   X0.4 X05.Sep Oct.14 X15.19
## 1          900                          1950 337432  269550 260286 238628
## 2          900                          1955 402845  315055 263266 254815
## 3          900                          1960 430565  380319 309276 257899
## 4          900                          1965 477798  409020 372817 303891
## 5          900                          1970 522641  458298 403911 367789
## 6          900                          1975 543225  503753 452706 398384
##   X20.24 X25.29 X30.34 X35.39 X40.44 X45.49 X50.54 X55.59 X60.64 X65.69
## 1 221781 194424 166937 162917 147483 127415 107608  88601  73422  55106
## 2 231892 214878 187941 160385 155546 138743 119084  97441  76843  59322
## 3 248413 225957 208747 181632 153398 147699 130210 108435  85064  62665
## 4 251897 242692 219978 202499 174884 145701 138601 119505  95085  70256
## 5 297557 246921 237657 214330 196585 168438 137799 128954 107201  81023
## 6 361883 293531 243384 233137 209181 190299 161058 128755 116704  92385
##   X70.74 X75.79  X80. X80.84 X85.89 X90.94 X95.99 X100.
## 1  37360  21997 14202     NA     NA     NA     NA    NA
## 2  40346  23755 16158     NA     NA     NA     NA    NA
## 3  44018  25986 18061     NA     NA     NA     NA    NA
## 4  47382  29457 21032     NA     NA     NA     NA    NA
## 5  55168  32876 25340     NA     NA     NA     NA    NA
## 6  64337  38934 29743     NA     NA     NA     NA    NA
pyr <- read.csv("Session_2_POPULATION_BY_AGE_BOTH_SEXES.csv", header=T)
names(pyr)
##  [1] "Index"
##  [2] "Variant"
##  [3] "Major.area..region..country.or.area.."
##  [4] "sex"
##  [5] "Notes"
##  [6] "Country.code"
##  [7] "Reference.date..as.of.1.July."
##  [8] "X0.4"
##  [9] "X05.Sep"
## [10] "Oct.14"
## [11] "X15.19"
[...]
## [22] "X70.74"
## [23] "X75.79"
## [24] "X80."
## [25] "X80.84"
## [26] "X85.89"
## [27] "X90.94"
## [28] "X95.99"
## [29] "X100."
#make a new variable with names of all variables:
#make a new variable with names of all variables:
vars <- names(pyr)
#and change those variables names that start with an X
age <- c(paste(seq(0, 75, by=5), "-", seq(4, 79, by=5)), "80+", paste(seq(80, 95, by=5), "-", seq(84, 99, by=5)), "100+")
age
##  [1] "0 - 4"   "5 - 9"   "10 - 14" "15 - 19" "20 - 24" "25 - 29" "30 - 34"
##  [8] "35 - 39" "40 - 44" "45 - 49" "50 - 54" "55 - 59" "60 - 64" "65 - 69"
## [15] "70 - 74" "75 - 79" "80+"     "80 - 84" "85 - 89" "90 - 94" "95 - 99"
## [22] "100+"
names(pyr) <- c(vars[1], vars[2], "Major.Area", "sex", vars[5], vars[6], "year", age)
names(pyr)[1:15]
##  [1] "Index"        "Variant"      "Major.Area"   "sex"
##  [5] "Notes"        "Country.code" "year"         "0 - 4"
##  [9] "5 - 9"        "10 - 14"      "15 - 19"      "20 - 24"
## [13] "25 - 29"      "30 - 34"      "35 - 39"
library(tidyr)
# transform the data from wide to long format
pyr <- gather(pyr, "age.group", "value", 8:29)
head(pyr)
##   Index   Variant Major.Area  sex Notes Country.code year age.group  value
## 1     1 Estimates      WORLD both                900 1950     0 - 4 337432
## 2     2 Estimates      WORLD both                900 1955     0 - 4 402845
## 3     3 Estimates      WORLD both                900 1960     0 - 4 430565
## 4     4 Estimates      WORLD both                900 1965     0 - 4 477798
## 5     5 Estimates      WORLD both                900 1970     0 - 4 522641
## 6     6 Estimates      WORLD both                900 1975     0 - 4 543225
#replace all NA with 0
library(dplyr)
is.na(pyr$value) <- 0
pyr.g <- pyr %>%
 filter(Major.Area=="Georgia"&sex!="both") # exclude "both"

#create an order vector to sort data
o <- seq(1,22, by=1) # 22 is the number of age groups length(unique(pyr$age.group))
oo <- rep(o,28) # 28 number of years
order <- as.vector(sort(oo, decreasing=F))
pyr.g$order <- order
breaks <- pyr.g$age.group
library(ggplot2)
###
# get rid of the 80+ abridged age group
pyr.g1 <- pyr.g[-c(which(pyr.g$age.group=="80+")),]
### simple pyramid plot
p <- ggplot(pyr.g1, aes(x=age.group, y=value, fill=factor(sex)))+
geom_bar(data=pyr.g1 %>%
filter(sex=="female"&year=="2015"),
aes(x=reorder(age.group, order), y=value), stat="identity")+
geom_bar(data=pyr.g1 %>%
filter(sex=="male"&year=="2015"),
aes(x=reorder(age.group, order), y=-value), stat="identity")+ #negative value for males not to overlap; reorder values of age group by order; "identity" is only for bar charts
coord_flip()+ #bending function: flip the coordinates
labs(x = "", y = "")+
scale_fill_manual(values = c(female = "red", male = "blue"), name="")+
scale_x_discrete(breaks=c(paste(seq(0,90, by=10),"-", seq(4,94, by=10)), "100+"),labels=c(paste(seq(0,90, by=10),"-", seq(4,94, by=10)), "100+" ))+ #not to show all the age groups all the time
scale_y_continuous(breaks=seq(-200,200,25),labels=abs(seq(-200,200,25)))+ #tell R t paste absolute numbers of values not to have negative values on graph
theme_bw()+
theme(axis.text.x = element_text(size=10, color="black"), # size of x axis text
axis.text.y = element_text(size=10, color="black"))

pyr1

#############################################
### STEP 2: add lines/bars to compare other years
#############################################
p+
geom_line(data=pyr.g1 %>%
filter(sex=="male"&year=="1975"),
aes(x=reorder(age.group, order), y=-value), colour="lightblue", group=1)+
geom_line(data=pyr.g1 %>%
filter(sex=="female"&year=="1975"),
aes(x=reorder(age.group, order), y=value), colour="pink", group=1)

pyr2

# bars: since in ggplot the last plot is
#the one that appears on top (hiding everything underneath),
#we can add alpha=0.5 to add some transparence, 1 being the
#full color
p+
geom_bar(data=pyr.g1 %>%
filter(sex=="male"&year=="1975"),
aes(x=reorder(age.group, order), y=-value), fill="lightblue", alpha=.5,stat="identity")+
geom_bar(data=pyr.g1 %>%
filter(sex=="female"&year=="1975"),
aes(x=reorder(age.group, order), y=value), fill="pink", alpha=.5, stat="identity")

pyr3

#######################################################################
# STEP 3: add different legends for the two years: now we only have one for the sex, as the fill factors for all 4 geom_bar(s) is the same
#
ggplot(pyr.g1, aes(x=age.group, y=value, fill=factor(sex), col=factor(year)))+ # add different colors for the two years 1975 and 2015 by adding col=factor(year)
# this part stays the same
geom_bar(data=pyr.g1 %>%
filter(sex=="female"&year=="2015"),
aes(x=reorder(age.group, order), y=value), stat="identity")+
geom_bar(data=pyr.g1 %>%
filter(sex=="male"&year=="2015"),
aes(x=reorder(age.group, order), y=-value), stat="identity")+
geom_bar(data=pyr.g1 %>%
filter(sex=="male"&year=="1975"),
aes(x=reorder(age.group, order),y=-value), alpha=.5,stat="identity")+
geom_bar(data=pyr.g1 %>%
filter(sex=="female"&year=="1975"),
aes(x=reorder(age.group, order), y=value), alpha=.5, stat="identity")+
coord_flip()+
labs(x = "", y = "")+
scale_x_discrete(breaks=c(paste(seq(0,90, by=10),"-", seq(4,94, by=10)) , "100+"),labels=c(paste(seq(0,90, by=10),"-", seq(4,94, by=10)), "100+" ))+
scale_y_continuous(breaks=seq(-200,200,25),labels=abs(seq(-200,200,25)))+
theme_bw()+
theme(axis.text.x = element_text(size=10, color="black"),
axis.text.y = element_text(size=10, color="black"))+
# add the legends with scale_fill_manual which controls the filling colors for sex and scale_color_manual which controls the border color that distinguisces the two years
scale_fill_manual(values = c(female = "red", male = "blue"), name="")+
scale_color_manual(values=c("1975"="black", "2015"="grey"), name="" )+
# and I want the year legend squares to look empty
guides(colour = guide_legend(override.aes = list(alpha = 0))) #makes the squares for the years legend empty of any color

pyr4

################################################################
## STEP 4: one pyramid plot for each year in one page with facet_wrap
##
ggplot(pyr.g1, aes(x=age.group, y=value, fill=factor(sex)))+
geom_bar(data=pyr.g1 %>%
filter(sex=="male"),
aes(x=reorder(age.group, order), y=-value), stat="identity")+
geom_bar(data=pyr.g1 %>%
filter(sex=="female"),
aes(x=reorder(age.group, order), y=value), stat="identity")+
coord_flip()+
labs(x = "", y = "")+
scale_x_discrete(breaks=c( paste(seq(0,90, by=10),"-", seq(4,94, by=10)), "100+" ))+
scale_y_continuous(breaks=seq(-300,300,100),labels=abs(seq(-300,300,100)))+
scale_fill_manual(values = c(female = "red", male = "blue"), name="")+
theme_bw()+
theme(axis.text.x = element_text(size=10, color="black"),
axis.text.y = element_text(size=10, color="black"))+
facet_wrap(~year)

Untitled

pyr.ar <- pyr %>%
filter(Major.Area=="Armenia"&sex!="both") # exclude "both"
pyr.az <- pyr %>%
filter(Major.Area=="Azerbaijan"&sex!="both") # exclude "both"
pyr.ar$order <- order
pyr.az$order <- order
pyr.c <- rbind(pyr.g, pyr.ar, pyr.az)
pyr.c1 <- pyr.c[-c(which(pyr.c$age.group=="80+")),] 

ggplot(pyr.c1,
aes(x=age.group, y=value,
fill=factor(Major.Area)))+
 geom_bar(data=pyr.c1 %>%
filter(sex=="female"&year=="2015"),
aes(x=reorder(age.group, order), y=value), stat="identity")+
geom_bar(data=pyr.c1 %>%
filter(sex=="male"&year=="2015"),
aes(x=reorder(age.group, order), y=-value),
stat="identity")+
coord_flip()+
 labs(x = "", y = "")+
scale_x_discrete(breaks=c(paste(seq(0,90, by=10),"-", seq(4,94, by=10)) , "100+"),
labels=c(paste(seq(0,90, by=10),"-", seq(4,94, by=10)), "100+" ))+
 scale_y_continuous(breaks=seq(-400,400,200),
labels=abs(seq(-400,400,200)))+
 theme_bw()+
scale_fill_manual(values = c(Armenia = "red",
Georgia="green", Azerbaijan = "blue"), name="")+
theme(axis.text.x = element_text(size=10, color="black"),
axis.text.y = element_text(size=10, color="black"),
legend.position="none")+
facet_wrap(~Major.Area)
#facet_wrap(~Major.Area, scales="free_x")

Untitled3

And with scales=”free_x”

Untitled1


Geofacet: Bangladesh 64 districts education

Geofacet example using World Bank data on Bangladesh education attainment

  1. set up grids
  2. upload data, source: World Bank
  3. plot and save

1. Grid for Bangladesh districts:

library(tidyverse)
library(geofacet)
library(ggthemes)
options(scipen = 99)
mygrid <- data.frame(
row = c(1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11),
col = c(3, 2, 3, 4, 3, 4, 5, 3, 4, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 9),
code = c("BG01","BG02","BG03","BG04","BG05","BG06","BG07","BG08","BG09","BG10","BG11","BG12","BG13","BG14","BG15","BG16","BG17","BG18","BG19","BG20","BG21","BG22","BG23","BG24","BG25","BG26","BG27","BG28","BG29","BG30","BG31","BG32","BG33","BG34","BG35","BG36","BG37","BG38","BG39","BG40","BG41","BG42","BG43","BG44","BG45","BG46","BG47","BG48","BG49","BG50","BG51","BG52","BG53","BG54","BG55","BG56","BG57","BG58","BG59","BG60","BG61","BG62","BG63", "BG64"),
name = c("Panchagar","Takurgaong","Nilphamar","Lamonirhat","Dinajpur","Rangpur","Kurigram","Jaipurat","Gaibandha","Naogaon","Bogra","Jamalpur","Sherpar","Mymensingh","Netrokona","Suramganj","Sylhet","Chapai","Rajshani","Nator","Sirajganj","Tangail","Gazipur","Kishoreganj","Habiganj","Moulvibazar","Kushtia","Pabna","Dhaka","Nardiaganj","Narsingdi","Brahmanbaria","Meherpur","Jhenaidah","Magura","Rajbari","Manikganj","Munshiganj","Comilla","Khagrachhari","Rangramati","Chuadanga","Jessore","Gopalganj","Faridpur","Madanipur","Shariyapur","Chandpur","Feni","Chittagong","Badanbari","Narail","Pirojpur","Barisal","Jhalkati","Laksimipur","Noakhali","Satkhira","Khulna","Bagerhat","Borguna","Patuakhali","Bhola","Cox's Bazar"),
stringsAsFactors = FALSE
)

Preview the grid:

geofacet::grid_preview(mygrid)

Screen Shot 2017-07-23 at 16.17.02.png

2. Data from World Bank

dt3<-structure(list(ordinal = c(58L, 58L, 58L, 58L, 58L, 58L, 58L, 34L, 56L, 57L, 34L, 56L, 57L, 34L, 56L, 57L, 34L, 56L, 57L, 34L, 56L, 57L, 34L, 56L, 57L, 34L, 56L, 57L, 53L, 55L, 59L, 53L, 55L, 59L, 53L, 55L, 59L, 53L, 55L, 59L, 53L, 55L, 59L, 53L, 55L, 59L, 53L, 55L, 59L, 47L, 54L, 47L, 54L, 47L, 54L, 47L, 54L, 47L, 54L, 47L, 54L, 47L, 54L, 22L, 27L, 30L, 33L, 45L, 48L, 63L, 64L, 22L, 27L, 30L, 33L, 45L, 48L, 63L, 64L, 22L, 27L, 30L, 33L, 45L, 48L, 63L, 64L, 22L, 27L, 30L, 33L, 45L, 48L, 63L, 64L, 22L, 27L, 30L, 33L, 45L, 48L, 63L, 64L, 22L, 27L, 30L, 33L, 45L, 48L, 63L, 64L, 22L, 27L, 30L, 33L, 45L, 48L, 63L, 64L, 20L, 23L, 46L, 49L, 51L, 52L, 60L, 61L, 62L, 20L, 23L, 46L, 49L, 51L, 52L, 60L, 61L, 62L, 20L, 23L, 46L, 49L, 51L, 52L, 60L, 61L, 62L, 20L, 23L, 46L, 49L, 51L, 52L, 60L, 61L, 62L, 20L, 23L, 46L, 49L, 51L, 52L, 60L, 61L, 62L, 20L, 23L, 46L, 49L, 51L, 52L, 60L, 61L, 62L, 20L, 23L, 46L, 49L, 51L, 52L, 60L, 61L, 62L, 8L, 18L, 28L, 29L, 40L, 50L, 8L, 18L, 28L, 29L, 40L, 50L, 8L, 18L, 28L, 29L, 40, 50L, 8L, 18L, 28L, 29L, 40L, 50L, 8L, 18L, 28L, 29L, 40L, 50L, 8L, 18L, 28L, 29L, 40L, 50L, 8L, 18L, 28L, 29L, 40L, 50L, 11L, 25L, 26L, 31L, 38L, 41L, 42L, 11L, 25L, 26L, 31L, 38L, 41L, 42L, 11L, 25L, 26L, 31L, 38L, 41L, 42L, 11L, 25L, 26L, 31L, 38L, 41L, 42L, 11L, 25L, 26L, 31L, 38L, 41L, 42L, 11L, 25L, 26L, 31L, 38L, 41L, 42L, 11L, 25L, 26L, 31L, 38L, 41L, 42L, 9L, 13L, 14L, 17L, 19L, 21L, 24L, 32L, 36L, 37L, 9L, 13L, 14L, 17L, 19L, 21L, 24L, 32L, 36L, 37L, 9L, 13L, 14L, 17L, 19L, 21L, 24L, 32L, 36L, 37L, 9L, 13L, 14L, 17L, 19L, 21L, 24L, 32L, 36L, 37L, 9L, 13L, 14L, 17L, 19L, 21L, 24L, 32L, 36L, 37L, 9L, 13L, 14L, 17L, 19L, 21L, 24L, 32L, 36L, 37L, 9L, 13L, 14L, 17L, 19L, 21L, 24L, 32L, 36L, 37L, 2L, 4L,6L, 7L, 10L, 15L, 16L, 43L, 2L, 4L, 6L, 7L, 10L, 15L, 16L, 43L, 2L, 4L, 6L, 7L, 10L, 15L, 16L, 43L, 2L, 4L, 6L, 7L, 10L, 15L, 16L, 43L, 2L, 4L, 6L, 7L, 10L, 15L, 16L, 43L, 2L, 4L, 6L, 7L, 10L, 15L, 16L, 43L, 2L, 4L, 6L, 7L, 10L, 15L, 16L, 43L, 1L, 3L, 5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"
), class = "factor"), Zila.Name = structure(c(50L, 50L, 50L, 50L, 50L, 50L, 50L, 63L, 33L, 47L, 63L, 33L, 47L, 63L, 33L, 47L, 63L, 33L, 47L, 63L, 33L, 47L, 63L, 33L, 47L, 63L, 33L, 47L, 15L, 30L, 56L, 15L, 30L, 56L, 15L, 30L, 56L, 15L, 30L, 56L, 15L, 30L, 56L, 15L, 30L, 56L, 15L, 30L, 56L, 26L, 18L, 26L, 18L, 26L, 18L,
26L, 18L, 26L, 18L, 26L, 18L, 26L, 18L, 22L, 40L, 46L, 59L, 6L, 41L, 61L, 62L, 22L, 40L, 46L, 59L, 6L, 41L, 61L, 62L, 22L, 40L, 46L, 59L, 6L, 41L, 61L, 62L, 22L, 40L, 46L, 59L, 6L, 41L, 61L, 62L, 22L, 40L, 46L, 59L, 6L, 41L, 61L, 62L, 22L, 40L, 46L, 59L, 6L, 41L, 61L, 62L, 22L, 40L, 46L, 59L, 6L, 41L, 61L, 62L, 19L, 29L, 9L, 45L, 54L, 60L, 64L, 21L, 37L, 19L, 29L, 9L, 45L, 54L, 60L, 64L, 21L, 37L, 19L, 29L, 9L, 45L, 54L, 60L, 64L, 21L, 37L, 19L, 29L, 9L, 45L, 54L, 60L, 64L, 21L, 37L, 19L, 29L, 9L, 45L, 54L, 60L, 64L, 21L, 37L, 19L, 29L, 9L, 45L, 54L, 60L, 64L, 21L, 37L, 19L, 29L, 9L, 45L, 54L, 60L, 64L, 21L, 37L, 7L, 14L, 43L, 44L, 31L, 49L, 7L, 14L, 43L, 44L, 31L, 49L, 7L, 14L, 43L, 44L, 31L, 49L, 7L, 14L, 43L, 44L, 31L, 49L, 7L, 14L, 43L, 44L, 31L, 49L, 7L, 14L, 43L, 44L, 31L, 49L, 7L, 14L, 43L, 44L, 31L, 49L, 12L, 36L, 39L, 53L, 25L, 35L, 38L, 12L, 36L, 39L, 53L, 25L, 35L, 38L, 12L, 36L, 39L, 53L, 25L, 35L, 38L, 12L, 36L, 39L, 53L, 25L, 35L, 38L, 12L, 36L, 39L, 53L, 25L, 35L, 38L, 12L, 36L, 39L, 53L,
25L, 35L, 38L, 12L, 36L, 39L, 53L, 25L, 35L, 38L, 8L, 17L, 27L, 55L, 16L, 20L, 34L, 58L, 11L, 23L, 8L, 17L, 27L, 55L, 16L, 20L, 34L, 58L, 11L, 23L, 8L, 17L, 27L, 55L, 16L, 20L, 34L, 58L, 11L, 23L, 8L, 17L, 27L, 55L, 16L, 20L, 34L, 58L, 11L, 23L, 8L, 17L, 27L, 55L, 16L, 20L, 34L, 58L, 11L, 23L, 8L, 17L, 27L, 55L, 16L, 20L, 34L, 58L, 11L, 23L, 8L, 17L, 27L, 55L, 16L, 20L, 34L, 58L, 11L, 23L, 4L, 24L, 52L, 2L, 10L, 32L, 48L, 42L, 4L, 24L, 52L, 2L, 10L, 32L, 48L, 42L, 4L, 24L, 52L, 2L, 10L, 32L, 48L, 42L, 4L, 24L, 52L, 2L, 10L, 32L, 48L, 42L, 4L, 24L, 52L, 2L, 10L, 32L, 48L, 42L, 4L, 24L, 52L, 2L, 10L, 32L, 48L, 42L, 4L, 24L, 52L, 2L, 10L, 32L, 48L, 42L, 3L, 5L, 51L, 13L, 1L, 28L, 57L, 3L, 5L, 51L, 13L, 1L, 28L, 57L, 3L, 5L, 51L, 13L, 1L, 28L, 57L, 3L, 5L, 51L, 13L, 1L, 28L, 57L, 3L, 5L, 51L, 13L, 1L, 28L, 57L, 3L, 5L, 51L, 13L, 1L, 28L, 57L, 3L, 5L, 51L, 13L, 1L, 28L, 57L), .Label = c("BAGERHAT", "BANDARBAN", "BARGUNA", "BARISAL",
"BHOLA", "BOGRA", "BRAHMANBARIA", "CHANDPUR", "CHAPAI NABABGANJ", "CHITTAGONG", "CHUADANGA", "COMILLA", "COX'S BAZAR", "DHAKA", "DINAJPUR", "FARIDPUR", "FENI", "GAIBANDHA", "GAZIPUR", "GOPALGANJ", "HABIGANJ", "JAMALPUR", "JESSORE", "JHALOKATI", "JHENAIDAH", "JOYPURHAT", "KHAGRACHHARI", "KHULNA", "KISHOREGANJ", "KURIGRAM", "KUSHTIA", "LAKSHMIPUR", "LALMONIRHAT", "MADARIPUR", "MAGURA",
"MANIKGANJ", "MAULVIBAZAR", "MEHERPUR", "MUNSHIGANJ", "MYMENSINGH", "NAOGAON", "NARAIL", "NARAYANGANJ", "NARSINGDI", "NATORE", "NETRAKONA", "NILPHAMARI", "NOAKHALI", "PABNA", "PANCHAGARH", "PATUAKHALI", "PIROJPUR", "RAJBARI", "RAJSHAHI", "RANGAMATI", "RANGPUR", "SATKHIRA", "SHARIATPUR", "SHERPUR", "SIRAJGANJ", "SUNAMGANJ", "SYLHET", "TANGAIL", "THAKURGAON"), class = "factor"), name = structure(c(50L, 50L, 50L, 50L, 50L, 50L, 50L, 64L, 33L, 47L, 64L, 33L, 47L, 64L, 33L, 47L, 64L, 33L, 47L, 64L, 33L, 47L, 64L, 33L, 47L, 64L, 33L,
47L, 15L, 30L, 55L, 15L, 30L, 55L, 15L, 30L, 55L, 15L, 30L, 55L, 15L, 30L, 55L, 15L, 30L, 55L, 15L, 30L, 55L, 22L, 18L, 22L, 18L, 22L, 18L, 22L, 18L, 22L, 18L, 22L, 18L, 22L, 18L, 23L, 40L, 46L, 59L, 5L, 41L, 61L, 62L, 23L, 40L, 46L, 59L, 5L, 41L, 61L, 62L, 23L, 40L, 46L, 59L, 5L, 41L, 61L, 62L, 23L, 40L, 46L, 59L, 5L, 41L, 61L, 62L, 23L, 40L, 46L, 59L, 5L, 41L, 61L, 62L, 23L, 40L, 46L, 59L, 5L, 41L, 61L, 62L, 23L, 40L, 46L, 59L, 5L, 41L, 61L, 62L, 19L, 29L, 9L, 45L, 54L, 60L, 63L, 21L, 38L, 19L, 29L, 9L, 45L, 54L, 60L, 63L, 21L, 38L, 19L, 29L, 9L, 45L, 54L, 60L, 63L, 21L, 38L, 19L, 29L, 9L, 45L, 54L, 60L, 63L, 21L, 38L, 19L, 29L, 9L, 45L, 54L, 60L, 63L, 21L, 38L, 19L, 29L, 9L, 45L, 54L, 60L,
63L, 21L, 38L, 19L, 29L, 9L, 45L, 54L, 60L, 63L, 21L, 38L, 7L, 14L, 43L, 44L, 31L, 49L, 7L, 14L, 43L, 44L, 31L, 49L, 7L, 14L, 43L, 44L, 31L, 49L, 7L, 14L, 43L, 44L, 31L, 49L, 7L, 14L, 43L, 44L, 31L, 49L, 7L, 14L, 43L, 44L, 31L, 49L, 7L, 14L, 43L, 44L, 31L, 49L, 12L, 36L, 39L, 53L, 26L, 35L, 37L, 12L, 36L, 39L, 53L, 26L, 35L, 37L, 12L, 36L, 39L, 53L, 26L, 35L, 37L, 12L, 36L, 39L, 53L, 26L, 35L, 37L, 12L, 36L, 39L, 53L, 26L, 35L, 37L, 12L, 36L, 39L, 53L, 26L, 35L, 37L, 12L, 36L, 39L, 53L, 26L, 35L, 37L, 8L, 17L, 27L, 56L, 16L, 20L, 34L, 58L, 11L, 24L, 8L, 17L, 27L, 56L, 16L, 20L, 34L, 58L, 11L, 24L, 8L, 17L, 27L, 56L, 16L, 20L, 34L, 58L, 11L, 24L, 8L, 17L, 27L, 56L, 16L, 20L, 34L, 58L, 11L, 24L,
8L, 17L, 27L, 56L, 16L, 20L, 34L, 58L, 11L, 24L, 8L, 17L, 27L, 56L, 16L, 20L, 34L, 58L, 11L, 24L, 8L, 17L, 27L, 56L, 16L, 20L, 34L, 58L, 11L, 24L, 3L, 25L, 52L, 1L, 10L, 32L, 48L, 42L, 3L, 25L, 52L, 1L, 10L, 32L, 48L, 42L, 3L, 25L, 52L, 1L, 10L, 32L, 48L, 42L, 3L, 25L, 52L, 1L, 10L, 32L, 48L, 42L, 3L, 25L, 52L,
1L, 10L, 32L, 48L, 42L, 3L, 25L, 52L, 1L, 10L, 32L, 48L, 42L, 3L, 25L, 52L, 1L, 10L, 32L, 48L, 42L, 6L, 4L, 51L, 13L, 2L, 28L, 57L, 6L, 4L, 51L, 13L, 2L, 28L, 57L, 6L, 4L, 51L, 13L, 2L, 28L, 57L, 6L, 4L, 51L, 13L, 2L, 28L, 57L, 6L, 4L, 51L, 13L, 2L, 28L, 57L, 6L, 4L, 51L, 13L, 2L, 28L, 57L, 6L, 4L, 51L, 13L, 2L, 28L, 57L), .Label = c("Badanbari", "Bagerhat", "Barisal", "Bhola", "Bogra", "Borguna", "Brahmanbaria", "Chandpur", "Chapai", "Chittagong", "Chuadanga", "Comilla", "Cox's Bazar", "Dhaka", "Dinajpur", "Faridpur", "Feni", "Gaibandha", "Gazipur", "Gopalganj", "Habiganj", "Jaipurat", "Jamalpur", "Jessore", "Jhalkati", "Jhenaidah", "Khagrachhari", "Khulna", "Kishoreganj", "Kurigram", "Kushtia", "Laksimipur", "Lamonirhat", "Madanipur", "Magura", "Manikganj", "Meherpur", "Moulvibazar", "Munshiganj", "Mymensingh", "Naogaon", "Narail",
"Nardiaganj", "Narsingdi", "Nator", "Netrokona", "Nilphamar", "Noakhali", "Pabna", "Panchagar", "Patuakhali", "Pirojpur", "Rajbari", "Rajshani", "Rangpur", "Rangramati", "Satkhira", "Shariyapur", "Sherpar", "Sirajganj", "Suramganj", "Sylhet", "Takurgaong", "Tangail"), class = "factor"), row = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5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, 2L, 5L, 7L, 6L, 9L, 4L, 3L, 2L, 5L, 7L, 6L, 9L, 4L, 3L, 2L, 5L, 7L, 6L, 9L, 4L, 3L, 2L), code = structure(c(12L, 12L, 12L, 12L, 12L, 12L, 12L, 1L, 3L, 2L, 1L, 3L, 2L, 1L, 3L, 2L, 1L, 3L, 2L, 1L, 3L, 2L, 1L, 3L, 2L, 1L, 3L, 2L, 4L, 6L, 5L, 4L, 6L, 5L, 4L, 6L, 5L, 4L, 6L, 5L, 4L, 6L, 5L, 4L, 6L, 5L, 4L, 6L, 5L, 7L, 13L, 7L, 13L, 7L, 13L, 7L, 13L, 7L, 13L, 7L, 13L, 7L, 13L, 10L, 15L, 16L, 14L, 9L, 8L, 11L, 17L, 10L, 15L, 16L, 14L, 9L, 8L, 11L, 17L, 10L, 15L, 16L, 14L, 9L, 8L, 11L, 17L, 10L, 15L, 16L, 14L, 9L, 8L, 11L, 17L, 10L, 15L, 16L, 14L, 9L, 8L, 11L, 17L, 10L, 15L, 16L, 14L, 9L, 8L, 11L, 17L, 10L, 15L, 16L, 14L, 9L, 8L, 11L, 17L, 23L, 24L, 18L, 20L, 19L, 21L,22L,25L,26L,23L,24L,18L,20L,19L,21L,22L,25L,26L,23L,24L,
18L,20L,19L,21L,22L,25L,26L,23L,24L,18L,20L,19L,21L, 22L,25L,26L,23L, 24L, 18L, 20L, 19L, 21L, 22L, 25L, 26L, 23L, 24L, 18L, 20L, 19L, 21L, 22L, 25L, 26L, 23L, 24L, 18L, 20L, 19L, 21L, 22L, 25L, 26L, 32L, 29L, 30L, 31L, 27L, 28L, 32L, 29L, 30L, 31L, 27L, 28L, 32L, 29L, 30L, 31L, 27L, 28L, 32L, 29L, 30L, 31L, 27L, 28L, 32L, 29L, 30L, 31L, 27L, 28L, 32L, 29L, 30L, 31L, 27L, 28L, 32L, 29L, 30L, 31L, 27L, 28L, 39L, 37L, 38L, 36L, 34L, 35L, 33L, 39L, 37L, 38L, 36L, 34L, 35L, 33L, 39L, 37L, 38L, 36L, 34L, 35L, 33L, 39L, 37L, 38L, 36L, 34L, 35L, 33L, 39L, 37L, 38L, 36L, 34L, 35L, 33L, 39L, 37L, 38L, 36L, 34L, 35L, 33L, 39L, 37L, 38L, 36L, 34L, 35L, 33L, 48L, 49L, 40L, 41L, 45L, 44L, 46L, 47L, 42L, 43L, 48L, 49L, 40L, 41L, 45L, 44L, 46L, 47L, 42L, 43L, 48L, 49L, 40L, 41L, 45L, 44L, 46L, 47L, 42L, 43L, 48L, 49L, 40L, 41L, 45L, 44L, 46L, 47L, 42L, 43L, 48L, 49L, 40L, 41L, 45L, 44L, 46L, 47L, 42L, 43L, 48L, 49L, 40L, 41L, 45L, 44L, 46L, 47L, 42L, 43L, 48L,
49L, 40L, 41L, 45L, 44L, 46L, 47L, 42L, 43L, 54L, 55L, 53L, 51L, 50L, 56L, 57L, 52L, 54L, 55L, 53L, 51L, 50L, 56L, 57L, 52L, 54L, 55L, 53L, 51L, 50L, 56L, 57L, 52L, 54L, 55L, 53L, 51L, 50L, 56L, 57L, 52L, 54L, 55L, 53L, 51L, 50L, 56L, 57L, 52L, 54L, 55L, 53L, 51L, 50L, 56L, 57L, 52L, 54L, 55L, 53L, 51L, 50L, 56L, 57L, 52L, 61L, 63L, 62L, 64L, 60L, 59L, 58L, 61L, 63L, 62L, 64L, 60L, 59L, 58L, 61L, 63L, 62L, 64L, 60L, 59L, 58L, 61L, 63L, 62L, 64L, 60L, 59L, 58L, 61L, 63L, 62L, 64L, 60L, 59L, 58L, 61L, 63L, 62L, 64L, 60L, 59L, 58L, 61L, 63L, 62L, 64L, 60L, 59L, 58L), .Label = c(" BG02", " BG03", " BG04", " BG05", " BG06", " BG07", " BG08", " BG10", " BG11", " BG12", " BG16", "BG01", "BG09", "BG13", "BG14", "BG15", "BG17", "BG18", "BG19", "BG20", "BG21", "BG22", "BG23", "BG24", "BG25", "BG26", "BG27", "BG28", "BG29", "BG30", "BG31", "BG32", "BG33", "BG34", "BG35", "BG36", "BG37", "BG38", "BG39", "BG40", "BG41", "BG42", "BG43", "BG44", "BG45", "BG46", "BG47", "BG48", "BG49", "BG50", "BG51", "BG52", "BG53", "BG54", "BG55", "BG56", "BG57", "BG58", "BG59", "BG60", "BG61", "BG62", "BG63", "BG64"), class = "factor"),
type = structure(c(1L, 2L, 3L, 4L, 1L, 3L, 4L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 1L, 1L, 1L, 3L, 3L, 3L, 4L, 4L, 4L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 1L, 1L, 1L, 3L, 3L, 3L, 4L, 4L, 4L, 1L, 1L, 2L, 2L,
3L, 3L, 4L, 4L, 1L, 1L, 3L, 3L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 3L,
3L, 3L, 3L, 3L, 3L, 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.1, 64.2, 66.9, 53.8, 53.7, 68.7, 50.5, 21.3,     29.1, 26.2, 23, 30.1, 33.9, 25, 34.6, 9.1, 10.2, 7.7, 8.3,     13, 10.1, 5.2, 11.7, 2.3, 2.6, 1.9, 1.8, 3.1, 2.3, 1.1, 3.2, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3, 12.8, 12.8,     12.8, 12.8, 12.8, 12.8, 12.8, 12.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 35.4, 62.1, 59.7, 54.4, 48.4, 60.9, 55, 61.6, 53.9, 43.3, 28.1, 29.2, 32, 33, 27.2, 30.4, 30.2, 35.6, 17.5, 8.1, 8.7, 10.7, 13.5, 9.7, 11.3, 6.9, 8.7, 3.8, 1.8, 2.3, 2.8, 5.1, 2.2, 3.2, 1.3, 1.8, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3, 12.8, 12.8, 12.8, 12.8, 12.8, 12.8,     12.8, 12.8, 12.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8,     3.8, 56.8, 28.8, 42.7, 51.7, 57, 56.7, 32.1, 34.8, 39.1,     34.6, 28.6, 29.1, 9.4, 23.3, 14.8, 11.3, 11.5, 11.3, 1.7,     13.1, 3.5, 2.4, 2.9, 2.8, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3,     12.8, 12.8, 12.8, 12.8, 12.8, 12.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 47.3, 56.1, 49, 56.7, 54.3, 53, 59.8, 36.1, 31.8, 38.4,     31, 33.1, 33.3, 29.9, 13.9, 10, 10.8, 10, 10.1, 11.2, 8.2,     2.7, 2.1, 1.8, 2.4, 2.5, 2.6, 2, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3, 12.8, 12.8, 12.8, 12.8, 12.8, 12.8, 12.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 44.7, 38.8, 59.3, 57, 54.5, 46.4, 56, 58.9, 55, 46.5, 40.1, 41.1, 29.5, 29, 32.8, 40, 32.6, 32.3, 34.3, 36.5, 12.9, 17, 9.3, 11.5, 10, 11, 9.2, 7.3, 8.9, 13.4, 2.3, 3.1, 1.9, 2.5, 2.6, 2.6, 2.1, 1.5, 1.8, 3.5, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3, 12.8, 12.8, 12.8, 12.8, 12.8, 12.8, 12.8, 12.8,  12.8, 12.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 39.8, 33.8, 36.6, 70, 38.9, 52.9, 47.6, 49.4, 41.2, 46, 45.9, 20.9, 36.3, 34.8, 38.2, 36.8, 15.2, 17.1, 14.4, 7.6, 19.1, 10.4, 12, 11.3, 3.8, 3.1, 3, 1.5, 5.8, 2, 2.2, 2.5, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3, 12.8,  12.8, 12.8, 12.8, 12.8, 12.8, 12.8, 12.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 43.6, 60.6, 48.1, 62.3, 42.8, 41.1, 51.3, 42.9, 28.6, 37.8, 27.1, 41.4, 36.7, 35.1, 11.1, 8.8, 11.7, 8.6, 12.8, 16.8, 10.9, 2.3, 2.1, 2.4, 2, 3, 5.4, 2.7, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3, 50.3, 12.8, 12.8, 12.8,    12.8, 12.8, 12.8, 12.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8    )), .Names = c("ordinal", "Division.Name", "Zila.Name", "name", "row", "col", "code", "type", "mean", "value"), class = "data.frame", row.names = c(NA, -448L))

3. Plot and save:

library(ggplot2)
p <- ggplot(dt3 , aes(type, value, fill=type))+
geom_col(position = position_dodge())+
scale_fill_manual(values = c("#7fc97f", "#beaed4","#fdc086","#ffff99"))+
themebw()+
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()),
plot.title=element_text(size=20, face="bold"))+
facet_geo(~name, grid = mygrid) +
labs(title = "Educational attainment in Bangladesh", fill="Edu attainment%",
caption = "By Aledemogr    Source: World Bank"
)
# ggsave("bgd1.png",height = 17, width = 10)</code>

 

bgd1

Geofacet: Nepal 75 districts

Screen Shot 2017-07-20 at 16.07.30row,col,code,name
1,4, NP01, Humla
1,5, NP02, Mugu
1,6, NP03, Dolpa
1,7, NP04, Mustang
1,8, NP05, Manang
2,9, NP06, Gorkha
2,1, NP07, Dharchula
2,2, NP08, Bajhang
2,3, NP09, Bajura
2,4, NP10, Kalikot
2,5, NP11, Jumla
2,6, NP12, Rukum
2,7, NP13, Myagdi
2,8, NP14, Kaski
2,10, NP15, Dhading
2,11, NP16, Rasuwa
2,12, NP17, Sindhupalchowk
2,13, NP18, Dolakha
2,14, NP19, Solukhumbu
2,15, NP20, Sankhuwasabha
2,16, NP21, Taplejung
3,9, NP22, Lamjung
3,1, NP23, Baitadi
3,2, NP24, Doti
3,3, NP25, Achham
3,4, NP26, Dailekh
3,5, NP27, Jajarkot
3,6, NP28, Rolpa
3,7, NP29, Baglung
3,8, NP30, Parbat
3,10, NP31, Nuwakot
3,11, NP32, Kavrepalanchok
3,12, NP33, Kathmandu
3,13, NP34, Okhaldhunga
3,14, NP35, Khotang
3,15, NP36, Bhojpur
3,16, NP37, Dhankuta
3,17, NP38, Tehrathum
4,9, NP39, Tanahun
4,1, NP40, Kanchanpur
4,2, NP41, Dadeldhura
4,3, NP42, Kailali
4,4, NP43, Surkhet
4,5, NP44, Salyan
4,6, NP45, Pyuthan
4,7, NP46, Gulmi
4,8, NP47, Syangja
4,10, NP48, Chitwan
4,11, NP49, Patan
4,12, NP50, Bhaktapur
4,13, NP51, Ramechhap
4,14, NP52, Udayapur
4,15, NP53, Sunsari
4,16, NP54, Panchthar
4,17, NP55, Ilam
5,9, NP56, Nawalparasi
5,4, NP57, Bardiya
5,5, NP58, Banke
5,6, NP59, Dang
5,7, NP60, Argakhanchi
5,8, NP61, Palpa
5,10, NP62, Parsa
5,11, NP63, Makwanpur
5,12, NP64, Sindhuli
5,13, NP65, Dhanussa
5,14, NP66, Siraha
5,15, NP67, Saptari
5,16, NP68, Morang
5,17, NP69, Jhapa
6,7, NP70, Kapilvastu
6,8, NP71, Rupandehi
6,10, NP72, Bara
6,11, NP73, Rahuttahat
6,12, NP74, Sarlahi
6,13, NP75, Mahottari

Geofacet grids: Nigeria Federal States

Geofacet grid for Nigeria’s 37 Federal States (below):

Screen Shot 2017-07-20 at 12.31.24.png

row,col,code,name
1,4,NG.KT,Katsina
1,5, NG.KN, Kano
1,2,NG.SO,Sokoto
1,3, NG.ZA, Zamfara
1,6, NG.JI, Jigawa
1,7, NG.YO, Yobe
2,2, NG.KE, Kebbi
2,3, NG.NI, Niger
2,4, NG.KD, Kaduna
2,7, NG.BO, Borno
2,6, NG.GO, Gombe
2,5, NG.BA, Bauchi
3,1, NG.OY, Oyo
3,2, NG.KW, Kwara
3,3,NG.FC, Abuja FCT
3,4, NG.NA, Nassarawa
3,6, NG.AD, Adamawa
3,5, NG.PL, Plateau
4,3, NG.EK, Ekiti
4,1, NG.OG, Ogun
4,2, NG.OS, Osun
4,4, NG.KO, Kogi
4,6, NG.TA, Taraba
4,5, NG.BE, Benue
5,3,NG.ED, Edo
5,1, NG.LA, Lagos
5,2, NG.ON, Ondo
5,6,NG.EB, Ebonyi
5,4, NG.AN, Anambra
5,5, NG.EN, Enugu
6,2, NG.DE, Delta
6,3, NG.IM, Imo
6,4,NG.AB, Abia
6,5, NG.CR, Cross River
7,3, NG.BY, Bayelsa
7,4, NG.RI, Rivers
7,5, NG.AK, Akwa Ibom

A nice example of hafen/geofacet from Washington Post to ggplot2

I’ve recently came across the hafen/geofacet function and was pondering to blog an example. Then, I came across a perfect example, thanks to ¬†kanishkamisra for working on the dataset & code and making it available via github here!

 

usa_vs_state1