Running packages

library(ggplot2)
library(tidyverse)
library(sp)
library(raster)
library(rgdal)
library(viridis)
library(readxl)

Input Data

vnm = getData("GADM", country="Vietnam", level=1)
vn = fortify(vnm, regions="VARNAME_1")
Covid_vaccine <- read_excel("Covid_vaccine.xlsx",sheet = "Sheet1", 
     col_types = c("text", "numeric", "numeric", 
         "numeric", "numeric", "numeric", 
         "numeric", "numeric", "numeric", 
         "numeric"))
attach(Covid_vaccine)

Creating objects (Regions with “s”)

vnm = getData("GADM", country="Vietnam", level=1)
vn=fortify(vnm,regions = "VARNAME_1")
## Regions defined for each Polygons
vnn = merge(vn,Covid_vaccine,by="id")

Making map and exporting into PC follow the s”setwd” with high quality png file

setwd("C:/Users/Admin/Desktop")
png('Figure 1.png',pointsize=6, width=5000, height=8500, res=1000)
ggplot(data=vnn, aes(x=long, y=lat, group=group))+geom_polygon(aes(fill=vnn$`Percentage of injection per pop`), show.legend = T)+labs(title = "Percentage of population vaccinated in Vietnam",caption = "Data source: Ministry of Health")+theme(plot.title = element_text(hjust = 0.5))+guides(fill=guide_legend(title="%"))+theme_void()+theme(legend.position = c(0.3,0.5))+theme(plot.caption.position = "plot",plot.caption = element_text(hjust = 0))+theme(plot.caption =element_text(face="italic",size = 6))+scale_fill_gradientn(colours=c("black","pink"))
## Warning: Use of `vnn$`Percentage of injection per pop`` is discouraged. Use
## `Percentage of injection per pop` instead.
dev.off()
## png 
##   2

Making map (data took from “object”, so vnn$data) with background

ggplot(data=vnn, aes(x=long, y=lat, group=group))+geom_polygon(aes(fill=vnn$Population), show.legend = T)+labs(title = "Population desity in Vietnam (>18 year old)",caption = "Data source: Ministry of Health")+theme(plot.title = element_text(hjust = 0.5))+guides(fill=guide_legend(title="%"))+theme(legend.position = c(0.3,0.5))+theme(plot.caption.position = "plot",plot.caption = element_text(hjust = 0))+theme(plot.caption =element_text(face="italic",size = 6))+scale_fill_gradientn(colours=c("black","grey"))
## Warning: Use of `vnn$Population` is discouraged. Use `Population` instead.

Making one more map

ggplot(data=vnn, aes(x=long, y=lat, group=group))+geom_polygon(aes(fill=vnn$No_injected), show.legend = T)+labs(title = "Number of injection in Vietnam (>18 year old)",caption = "Data source: Ministry of Health")+theme(plot.title = element_text(hjust = 0.5))+guides(fill=guide_legend(title="%"))+theme_void()+theme(legend.position = c(0.3,0.5))+theme(plot.caption.position = "plot",plot.caption = element_text(hjust = 0))+theme(plot.caption =element_text(face="italic",size = 6))+scale_fill_gradientn(colours=c("pink","red"))
## Warning: Use of `vnn$No_injected` is discouraged. Use `No_injected` instead.

Making map with breaking legend scale: 25,50,75,100

ggplot(data=vnn, aes(x=long, y=lat, group=group))+geom_polygon(aes(fill=vnn$`Percentage of 1st injection`), show.legend = T)+labs(title = "Percentage of 1st injection (>18 year old)",caption = "Data source: Ministry of Health")+theme(plot.title = element_text(hjust = 0.5))+guides(fill=guide_legend(title="%"))+theme_void()+theme(legend.position = c(0.3,0.5))+theme(plot.caption.position = "plot",plot.caption = element_text(hjust = 0))+theme(plot.caption =element_text(face="italic",size = 6))+scale_fill_continuous(breaks = c(25,50,75,100))
## Warning: Use of `vnn$`Percentage of 1st injection`` is discouraged. Use
## `Percentage of 1st injection` instead.

Making world map

world.map = map_data("world")
p = ggplot(data=world.map, aes(x=long, y=lat, group=group, fill=factor(group))) 
p + geom_polygon(col="white",show.legend=F) + theme(legend.position="none")+theme_void()

Making neighbour countries of Vietnam map

countries = c("Vietnam", "Thailand", "Cambodia", "Malaysia", "Laos","China")
asean = map_data("world", region = countries)
ggplot(asean, aes(x=long, y=lat, group=group, fill=factor(group))) + geom_polygon(col="white",show.legend = F) + theme(legend.position="none")+theme_void()

Making simple Vietnamese map (Legend is number =>region with “s”)

vnm = getData("GADM", country="Vietnam", level=1)
vn=fortify(vnm,regions = "VARNAME_1")
## Regions defined for each Polygons
ggplot(data=vn, aes(x=long, y=lat, group=group)) + geom_polygon(aes(fill=id), col="black", show.legend=T)+theme_void()

Making simple Vietnamese map (Legend is provinces/cities name =>region without “s”)

vnm = getData("GADM", country="Vietnam", level=1)
vn=fortify(vnm,region = "VARNAME_1")
ggplot(data=vn, aes(x=long, y=lat, group=group)) + geom_polygon(aes(fill=id), col="black", show.legend=T)+theme_void()

Data is following the order (Obligated)

City id

An Giang 1

Bình Phước 2

Bình Thuận 3

Cần Thơ 4

Cà Mau 5

Cao Bằng 6

Đắk lắk 7

Đắk Nông 8

Đồng Nai 9

Đồng Tháp 10

Đà Nẵng 11

Bạc Liêu 12

Điện Biên 13

Gia Lai 14

Hải Dương 15

Hải Phòng 16

Hậu Giang 17

Hồ Chí Minh 18

Hà Giang 19

Hà Nội 20

Hà Nam 21

Hà Tĩnh 22

Bắc Giang 23

Hòa Bình 24

Hưng Yên 25

Khánh Hòa 26

Kiên Giang 27

Kom Tum 28

Lạng Sơn 29

Lai Châu 30

Lâm Đồng 31

Lào Cai 32

Long An 33

Bắc Cạn 34

Nam Định 35

Nghệ An 36

Nình Bình 37

Ninh Thuận 38

Phú Thọ 39

Phú Yên 40

Quảng Bình 41

Quảng Nam 42

Quảng Ngãi 43

Quảng Ninh 44

Bắc Ninh 45

Quảng Trị 46

Sóc Trăng 47

Sơn La 48

Tây Ninh 49

Thừa Thiên Huế 50

Thái Bình 51

Thái Nguyên 52

Thanh Hóa 53

Tiền Giang 54

Trà Vinh 55

Bến Tre 56

Tuyên Quang 57

Vĩnh Long 58

Vĩnh Phúc 59

Yên Bái 60

Bà Rịa Vũng Tàu 61

Bình Định 62

Bình Dương 63