Loading libraries

library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.0.2
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5     ✓ purrr   0.3.4
## ✓ tibble  3.1.2     ✓ dplyr   1.0.7
## ✓ tidyr   1.1.3     ✓ stringr 1.4.0
## ✓ readr   1.4.0     ✓ forcats 0.5.1
## Warning: package 'ggplot2' was built under R version 4.0.2
## Warning: package 'tibble' was built under R version 4.0.2
## Warning: package 'tidyr' was built under R version 4.0.2
## Warning: package 'readr' was built under R version 4.0.2
## Warning: package 'dplyr' was built under R version 4.0.2
## Warning: package 'stringr' was built under R version 4.0.2
## Warning: package 'forcats' was built under R version 4.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(readxl)
library(ggplot2)
library(gridExtra)
## 
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
## 
##     combine
library(table1)
## 
## Attaching package: 'table1'
## The following objects are masked from 'package:base':
## 
##     units, units<-
library(compareGroups)
## Loading required package: SNPassoc
## Loading required package: haplo.stats
## Warning in .recacheSubclasses(def@className, def, env): undefined subclass
## "numericVector" of class "Mnumeric"; definition not updated
## Loading required package: survival
## Loading required package: mvtnorm
## Loading required package: parallel
## Registered S3 method overwritten by 'SNPassoc':
##   method            from       
##   summary.haplo.glm haplo.stats
library(ggthemes)
# options("scipen"=100, "digits"=0)

Data

vc = read_excel("~/Dropbox/Bao chi/Khoa hoc & Y te/Vaccine in VN/Vaccine dist in VN.xlsx")

vc$Region = factor(vc$Region, levels=c("Nam", "Trung", "Bắc", "QĐ", "CA"))

vc$total = vc$mRNA+vc$AstraZeneca
vc$pct = vc$mRNA/vc$total*100

Summary of data

vc %>%  group_by(Region) %>% summarise(sum(Moderna), sum(Pfizer), sum(mRNA), sum(AstraZeneca))
## # A tibble: 5 x 5
##   Region `sum(Moderna)` `sum(Pfizer)` `sum(mRNA)` `sum(AstraZeneca)`
##   <fct>           <dbl>         <dbl>       <dbl>              <dbl>
## 1 Nam            505680        208260      713940            1334600
## 2 Trung          389760         87750      477510                  0
## 3 Bắc            870240        202410     1072650                  0
## 4 QĐ              42000         35100       77100              25000
## 5 CA              33600         43290       76890              18000

Data visualization

ggplot(data=vc, aes(x=reorder(Province, total), y=total, fill=Province)) + geom_bar(stat="identity", width=0.8) + coord_flip() + theme_economist() + theme(legend.position="none") + labs(x="", y="Tổng số liều vaccine được phân phối")

ggplot(data=vc, aes(x=reorder(Province, pct), y=pct, fill=Province)) + geom_bar(stat="identity", width=0.8) + coord_flip() + theme_economist() + theme(legend.position="none") + labs(x="", y="Phần trăm vaccine mRNA được phân phối")

Region = c("Nam", "Trung", "Bắc", "Quân đội", "Công an")

Pct = c(35, 100, 100, 76, 81) 

dd = data.frame(Region, Pct)

dd$Region = factor(dd$Region, levels=c("Nam", "Trung", "Bắc", "Quân đội", "Công an") )
ggplot(data=dd, aes(x=Region, y=Pct, fill=Region, label=Pct)) + geom_bar(stat="identity") + geom_text(size=3, col="white", position=position_stack(vjust=0.95)) + theme(legend.position="none") + labs(x="", y="Phần trăm vaccine mRNA")