-
Notifications
You must be signed in to change notification settings - Fork 0
/
thai_excess_mortality.R
28 lines (21 loc) · 1.06 KB
/
thai_excess_mortality.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
dat <- read.csv(url('https://raw.githubusercontent.com/psunthud/examplecodes/main/thai_excess_mortality.csv'))
dat$Month <- as.Date(dat$Month, format='%Y-%m-%d')
dat <- dat[dat$Month >= '2021-04-01',]
dat$Month <- format(unique(dat$Month), "%m")
dat1 <- dat[,c("Month", "AveDeath1519")]
dat1 <- data.frame(dat1, "AveDeath1519")
colnames(dat1) <- c("Month", "Death", "Group")
dat2 <- dat[,c("Month", "NewCovidDeath")]
dat2 <- data.frame(dat2, "NewCovidDeath")
colnames(dat2) <- c("Month", "Death", "Group")
dat3 <- dat[,c("Month", "NewUndefinedExcessDeath")]
dat3 <- data.frame(dat3, "NewUndefinedExcessDeath")
colnames(dat3) <- c("Month", "Death", "Group")
datfull <- rbind(dat1, dat2, dat3)
datfull$Group <- factor(datfull$Group, levels=c("NewUndefinedExcessDeath", "NewCovidDeath", "AveDeath1519"))
levels(datfull$Group) <- c("Unidentified Excess Death", "Identified Covid Death", "Average Death 15-19")
datfull$Month <- as.numeric(datfull$Month)
library(ggplot2)
g <- ggplot(datfull, aes(x=Month, y=Death, fill=Group))
g <- g + geom_area()
g