Data

Open data on COVID-19 in Malaysia

Document

deaths_malaysia.csv

linelist_deaths.csv

Preliminary work

# library
library(tidyverse)
library(readr)

# Set working directory
# setwd("~/Library/CloudStorage/OneDrive-Personal/å·¥???/SKR5408/covid19-public-main")

# Import data
deaths_malaysia <- read_csv("epidemic/deaths_malaysia.csv")
death <- read_csv("epidemic/linelist/linelist_deaths.csv")

Analysing the situation in Malaysia

Exploratory data analysis was performed first. From deaths_malaysia.csv, the cumulative sum of the number of unvaccinated people who died over time, the cumulative sum of the number of partially vaccinated people who died (only one dose), and the cumulative sum of the number of fully vaccinated people who died (two or more doses) were calculated. Then, draw a time-series plot.

deaths_malaysia %>%
  ggplot() +
  geom_line(aes(date, cumsum(deaths_unvax), 
                color = 'death number of unvaccinated'), linewidth = 1.5) +
  geom_line(aes(date, cumsum(deaths_pvax), 
                color = 'death number of partially-vaccinated'), linewidth = 1.5) +
  geom_line(aes(date, cumsum(deaths_fvax+deaths_boost), 
                color = 'death number of fully-vaccinated'), linewidth = 1.5) +
  labs(
    title = 'Death number of partially and fully vaccinated',
    x = 'Date',
    y = 'Number'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 3))

From the graph we can identify a key issue: the cumulative number of deaths from full vaccination exceeds the cumulative number of deaths from partial vaccination in 2022.

deaths_malaysia %>%
  ggplot() +
  geom_line(aes(date, 1- cumsum(deaths_unvax)/cumsum(deaths_new_dod), 
                color = 'death proportion of vaccinated'), size = 1.5) +
  geom_line(aes(date, cumsum(deaths_pvax)/cumsum(deaths_new_dod), 
                color = 'death proportion of partially-vaccinated'), size = 1.5) +
  geom_line(aes(date, cumsum(deaths_fvax+deaths_boost)/cumsum(deaths_new_dod), 
                color = 'death proportion of fully-vaccinated'), size = 1.5) +
  labs(
    title = 'Death proportion of partially and fully vaccinated',
    x = 'Date',
    y = 'Proportion'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 3))

In terms of the ratio to the cumulative total number of deaths, the data are characterized as similar.

Further analysis of the specific data is required to explain the cause. Therefore the data from linelist_deaths.csv is used.

death
death %>%
  select(-date,-date_positive) %>%
  mutate(dose1=ifelse(!is.na(date_dose1), 1, 0)) %>%
  mutate(dose2=ifelse(!is.na(date_dose2), 1, 0)) %>%
  mutate(dose3=ifelse(!is.na(date_dose3), 1, 0)) %>%
  arrange(date_announced) %>%
  group_by(male, dose1, dose2, comorb) %>%
  summarize(average_age = mean(age))

The number of deaths at different vaccinations was calculated and divided into four groups according to age: children, adolescents, adults, and the elderly.

death_unvax <- death %>%
  select(-date,-date_positive) %>%
  mutate(dose1=ifelse(!is.na(date_dose1), 1, 0)) %>%
  mutate(dose2=ifelse(!is.na(date_dose2), 1, 0)) %>%
  mutate(dose3=ifelse(!is.na(date_dose3), 1, 0)) %>%
  arrange(date_announced) %>%
  filter(dose1 == 0 & dose2 == 0 & dose3 ==0) %>%
  mutate(child = ifelse(age>=0 & age<12,1,0)) %>%
  mutate(adolescent = ifelse(age>=12 & age<18,1,0)) %>%
  mutate(adult = ifelse(age>=18 & age<60,1,0)) %>%
  mutate(elderly = ifelse(age>=60,1,0))

death_pvax <- death %>%
  select(-date,-date_positive) %>%
  mutate(dose1=ifelse(!is.na(date_dose1), 1, 0)) %>%
  mutate(dose2=ifelse(!is.na(date_dose2), 1, 0)) %>%
  mutate(dose3=ifelse(!is.na(date_dose3), 1, 0)) %>%
  arrange(date_announced) %>%
  filter(dose1 == 1 & dose2 == 0 & dose3 ==0) %>%
  mutate(child = ifelse(age>=0 & age<12,1,0)) %>%
  mutate(adolescent = ifelse(age>=12 & age<18,1,0)) %>%
  mutate(adult = ifelse(age>=18 & age<60,1,0)) %>%
  mutate(elderly = ifelse(age>=60,1,0))

death_fvax <- death %>%
  select(-date,-date_positive) %>%
  mutate(dose1=ifelse(!is.na(date_dose1), 1, 0)) %>%
  mutate(dose2=ifelse(!is.na(date_dose2), 1, 0)) %>%
  mutate(dose3=ifelse(!is.na(date_dose3), 1, 0)) %>%
  arrange(date_announced) %>%
  filter(dose1==1 & dose2 == 1) %>%
  mutate(child = ifelse(age>=0 & age<12,1,0)) %>%
  mutate(adolescent = ifelse(age>=12 & age<18,1,0)) %>%
  mutate(adult = ifelse(age>=18 & age<60,1,0)) %>%
  mutate(elderly = ifelse(age>=60,1,0))

death_unvax: data on deaths without vaccination.

death_pvax: data on partially vaccinated deaths.

death_fvax: data on fully vaccinated deaths.

Then visualize the graphs with death_unvax, death_pvax, and death_fvax.

Impacts by age

Elderly

# Statistics on daily elderly deaths without vaccination
death_unvax_elderly <- death_unvax %>%
  mutate(date = date_announced) %>% 
  select(-date_announced) %>% # Change col name
  filter(elderly==1) %>%
  group_by(date) %>%
  summarise(count=sum(elderly))

# Supplementary complete date data
death_unvax_elderly <- deaths_malaysia %>%
  select(date) %>%
  left_join(death_unvax_elderly, by = 'date') %>%
  mutate(count = ifelse(is.na(count), 0, count))

# Similarly, the data on partial vaccination are transformed below
death_pvax_elderly <- death_pvax %>%
  mutate(date = date_announced) %>%
  select(-date_announced) %>%
  filter(elderly==1) %>%
  group_by(date) %>%
  summarise(count=sum(elderly))

death_pvax_elderly <- deaths_malaysia %>%
  select(date) %>%
  left_join(death_pvax_elderly, by = 'date') %>%
  mutate(count = ifelse(is.na(count), 0, count))

# Data on fully vaccination are transformed below
death_fvax_elderly <- death_fvax %>%
  mutate(date = date_announced) %>%
  select(-date_announced) %>%
  filter(elderly==1) %>%
  group_by(date) %>%
  summarise(count=sum(elderly))

death_fvax_elderly <- deaths_malaysia %>%
  select(date) %>%
  left_join(death_fvax_elderly, by = 'date') %>%
  mutate(count = ifelse(is.na(count), 0, count))

# Consolidate into one dataframe and replace column names
death_elderly <- death_unvax_elderly %>%
  left_join(death_pvax_elderly, by = 'date') %>%
  left_join(death_fvax_elderly, by = 'date') %>%
  mutate(unvax=count.x, pvax=count.y, fvax=count) %>%
  select(-count.x, -count.y, -count)

death_elderly is vaccine data on elderly patients who died. Plot the image based on death_elderly.

death_elderly %>%  
  ggplot() +
  geom_line(aes(date, cumsum(unvax), colour = 'unvax of elderly'), size=1.5) +
  geom_line(aes(date, cumsum(pvax), colour = 'pvax of elderly'), size=1.5, alpha = 1) +
  geom_line(aes(date, cumsum(fvax), colour = 'fvax of elderly'), size=1.5, alpha = 1) +
  labs(
    title = 'Death number of elderly un/vaccinated',
    x = 'Date',
    y = 'Number'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 3))

It can be seen that the cumulative number of fully vaccinated elderly deaths begins to exceed the cumulative number of partially vaccinated elderly patients by mid-2021.

The daily data are as follows.

death_elderly %>%
  ggplot() +
  geom_line(aes(date, unvax, color = 'deaths of unvaccinated'), alpha = 0.5, size = 1) +
  geom_line(aes(date, fvax, color = 'deaths of fully-vaccinated'), alpha = 0.5, size = 1) +
  geom_line(aes(date, pvax, color = 'deaths of partily-vaccinated'), alpha = 0.5, size = 1) +
  labs(
    title = 'Death people of partially and fully vaccinated [elderly]',
    x = 'Date',
    y = 'People per million'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 3))

Adult

# Statistics on daily adult deaths without vaccination
death_unvax_adult <- death_unvax %>%
  mutate(date = date_announced) %>%
  select(-date_announced) %>%
  filter(adult==1) %>%
  group_by(date) %>%
  summarise(count=sum(adult))

# Supplementary complete date data
death_unvax_adult <- deaths_malaysia %>%
  select(date) %>%
  left_join(death_unvax_adult, by = 'date') %>%
  mutate(count = ifelse(is.na(count), 0, count))

# partial vaccination
death_pvax_adult <- death_pvax %>%
  mutate(date = date_announced) %>%
  select(-date_announced) %>%
  filter(adult==1) %>%
  group_by(date) %>%
  summarise(count=sum(adult))

death_pvax_adult <- deaths_malaysia %>%
  select(date) %>%
  left_join(death_pvax_adult, by = 'date') %>%
  mutate(count = ifelse(is.na(count), 0, count))

# Fully vaccination
death_fvax_adult <- death_fvax %>%
  mutate(date = date_announced) %>%
  select(-date_announced) %>%
  filter(adult==1) %>%
  group_by(date) %>%
  summarise(count=sum(adult))

death_fvax_adult <- deaths_malaysia %>%
  select(date) %>%
  left_join(death_fvax_adult, by = 'date') %>%
  mutate(count = ifelse(is.na(count), 0, count))

# Complete data frame for plot
death_adult <- death_unvax_adult %>%
  left_join(death_pvax_adult, by = 'date') %>%
  left_join(death_fvax_adult, by = 'date') %>%
  mutate(unvax=count.x, pvax=count.y, fvax=count) %>%
  select(-count.x, -count.y, -count)
death_adult %>%  
  ggplot() +
  geom_line(aes(date, cumsum(unvax), colour = 'unvax of adult'), size=1.5) +
  geom_line(aes(date, cumsum(pvax), colour = 'pvax of adult'), size=1.5, alpha = 1) +
  geom_line(aes(date, cumsum(fvax), colour = 'fvax of adult'), size=1.5, alpha = 1) +
  labs(
    title = 'Death number of adult un/vaccinated',
    x = 'Date',
    y = 'Number'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 3))

Vaccines suppress the number of adult deaths. The cumulative number of deaths among fully vaccinated adults is lower than the number of deaths among partially vaccinated adults.

The chart below shows the daily data.

death_adult %>%
  ggplot() +
  geom_line(aes(date, unvax, color = 'deaths of unvaccinated'), alpha = 0.5, size = 1) +
  geom_line(aes(date, fvax, color = 'deaths of fully-vaccinated'), alpha = 0.5, size = 1) +
  geom_line(aes(date, pvax, color = 'deaths of partily-vaccinated'), alpha = 0.5, size = 1) +
  labs(
    title = 'Death people of partially and fully vaccinated [adult]',
    x = 'Date',
    y = 'People per million'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 3))

Adolescent

# unvax
death_unvax_adolescent <- death_unvax %>%
  mutate(date = date_announced) %>%
  select(-date_announced) %>%
  filter(adolescent==1) %>%
  group_by(date) %>%
  summarise(count=sum(adolescent))

death_unvax_adolescent <- deaths_malaysia %>%
  select(date) %>%
  left_join(death_unvax_adolescent, by = 'date') %>%
  mutate(count = ifelse(is.na(count), 0, count))

# pvax
death_pvax_adolescent <- death_pvax %>%
  mutate(date = date_announced) %>%
  select(-date_announced) %>%
  filter(adolescent==1) %>%
  group_by(date) %>%
  summarise(count=sum(adolescent))

death_pvax_adolescent <- deaths_malaysia %>%
  select(date) %>%
  left_join(death_pvax_adolescent, by = 'date') %>%
  mutate(count = ifelse(is.na(count), 0, count))

# fvax
death_fvax_adolescent <- death_fvax %>%
  mutate(date = date_announced) %>%
  select(-date_announced) %>%
  filter(adolescent==1) %>%
  group_by(date) %>%
  summarise(count=sum(adolescent))

death_fvax_adolescent <- deaths_malaysia %>%
  select(date) %>%
  left_join(death_fvax_adolescent, by = 'date') %>%
  mutate(count = ifelse(is.na(count), 0, count))

# Dateframe for plot
death_adolescent <- death_unvax_adolescent %>%
  left_join(death_pvax_adolescent, by = 'date') %>%
  left_join(death_fvax_adolescent, by = 'date') %>%
  mutate(unvax=count.x, pvax=count.y, fvax=count) %>%
  select(-count.x, -count.y, -count)
death_adolescent %>%  
  ggplot() +
  geom_line(aes(date, cumsum(unvax), colour = 'unvax of adolescent'), size=1.5) +
  geom_line(aes(date, cumsum(pvax), colour = 'pvax of adolescent'), size=1.5, alpha = 1) +
  geom_line(aes(date, cumsum(fvax), colour = 'fvax of adolescent'), size=1.5, alpha = 1) +
  labs(
    title = 'Death number of adolescent un/vaccinated',
    x = 'Date',
    y = 'Number'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 3))

The cumulative number of adolescents is too small to be very typical.

The daily data are as follows.

death_adolescent %>%
  ggplot() +
  geom_line(aes(date, unvax, color = 'deaths of unvaccinated'), alpha = 0.5, size = 1) +
  geom_line(aes(date, fvax, color = 'deaths of fully-vaccinated'), alpha = 0.5, size = 1) +
  geom_line(aes(date, pvax, color = 'deaths of partily-vaccinated'), alpha = 0.5, size = 1) +
  labs(
    title = 'Death people of partially and fully vaccinated [adolescent]',
    x = 'Date',
    y = 'People per million'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 3))

Child

# unvax
death_unvax_child <- death_unvax %>%
  mutate(date = date_announced) %>%
  select(-date_announced) %>%
  filter(child==1) %>%
  group_by(date) %>%
  summarise(count=sum(child))

death_unvax_child <- deaths_malaysia %>%
  select(date) %>%
  left_join(death_unvax_child, by = 'date') %>%
  mutate(count = ifelse(is.na(count), 0, count))

# pvax
death_pvax_child <- death_pvax %>%
  mutate(date = date_announced) %>%
  select(-date_announced) %>%
  filter(child==1) %>%
  group_by(date) %>%
  summarise(count=sum(child))

death_pvax_child <- deaths_malaysia %>%
  select(date) %>%
  left_join(death_pvax_child, by = 'date') %>%
  mutate(count = ifelse(is.na(count), 0, count))

# fvax
death_fvax_child <- death_fvax %>%
  mutate(date = date_announced) %>%
  select(-date_announced) %>%
  filter(child==1) %>%
  group_by(date) %>%
  summarise(count=sum(child))

death_fvax_child <- deaths_malaysia %>%
  select(date) %>%
  left_join(death_fvax_child, by = 'date') %>%
  mutate(count = ifelse(is.na(count), 0, count))

# Dataframe for plot
death_child <- death_unvax_child %>%
  left_join(death_pvax_child, by = 'date') %>%
  left_join(death_fvax_child, by = 'date') %>%
  mutate(unvax=count.x, pvax=count.y, fvax=count) %>%
  select(-count.x, -count.y, -count)
death_child %>%  
  ggplot() +
  geom_line(aes(date, cumsum(unvax), colour = 'unvax of child'), size=1.5) +
  geom_line(aes(date, cumsum(pvax), colour = 'pvax of child'), size=1.5, alpha = 1) +
  geom_line(aes(date, cumsum(fvax), colour = 'fvax of child'), size=1.5, alpha = 1) +
  labs(
    title = 'Death number of child un/vaccinated',
    x = 'Date',
    y = 'Number'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 3))

The child group was basically unvaccinated.

The daily data are as follows.

death_child %>%
  ggplot() +
  geom_line(aes(date, unvax, color = 'deaths of unvaccinated'), alpha = 0.5, size = 1) +
  geom_line(aes(date, fvax, color = 'deaths of fully-vaccinated'), alpha = 0.5, size = 1) +
  geom_line(aes(date, pvax, color = 'deaths of partily-vaccinated'), alpha = 0.5, size = 1) +
  labs(
    title = 'Death people of partially and fully vaccinated [child]',
    x = 'Date',
    y = 'People per million'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 3))

Comparison between different age groups

Build dataframe:

df_deathcount <- death_elderly %>%
  bind_cols(death_adult[2:4]) %>%
  bind_cols(death_adolescent[2:4]) %>%
  bind_cols(death_child[2:4]) %>%
  mutate(unvax_elderly = unvax...2) %>%
  mutate(pvax_elderly = pvax...3) %>%
  mutate(fvax_elderly = fvax...4) %>%
  mutate(unvax_adult = unvax...5) %>%
  mutate(pvax_adult = pvax...6) %>%
  mutate(fvax_adult = fvax...7) %>%
  mutate(unvax_adolescent = unvax...8) %>%
  mutate(pvax_adolescent = pvax...9) %>%
  mutate(fvax_adolescent = fvax...10) %>%
  mutate(unvax_child = unvax...11) %>%
  mutate(pvax_child = pvax...12) %>%
  mutate(fvax_child = fvax...13)
  
df_deathcount <- df_deathcount[c(1, 14:25)]
df_deathcount

A comparison of mortality data for the elderly and adults in the case of partial vaccination is shown below.

df_deathcount %>%
  ggplot() +
  geom_line(aes(date, pvax_elderly, color = 'pvax and elderly'), alpha = 0.5, size = 1.5) +
  geom_line(aes(date, pvax_adult, color = 'pvax and adult'), alpha = 0.5, size = 1.5) +
  # geom_line(aes(date, pvax_adolescent, color = 'pvax and adolescent'), alpha = 0.5, size = 1.5) +
  # geom_line(aes(date, pvax_child, color = 'pvax and child'), alpha = 0.5, size = 1.5) +
  labs(
    title = 'Death numbers of partially vaccinated',
    x = 'Date',
    y = 'People'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 2))

A comparison of mortality data for the elderly and adults in the case of fully vaccination is shown below.

df_deathcount %>%
  ggplot() +
  geom_line(aes(date, fvax_elderly, color = 'fvax and elderly'), alpha = 0.5, size = 1.5) +
  geom_line(aes(date, fvax_adult, color = 'fvax and adult'), alpha = 0.5, size = 1.5) +
  # geom_line(aes(date, fvax_adolescent, color = 'fvax and adolescent'), alpha = 0.5, size = 1.5) +
  # geom_line(aes(date, fvax_child, color = 'fvax and child'), alpha = 0.5, size = 1.5) +
  labs(
    title = 'Death numbers of fully vaccinated',
    x = 'Date',
    y = 'People'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 2))

Comparison of cumulative deaths:

df_deathcount %>%
  ggplot() +
  geom_line(aes(date, cumsum(pvax_elderly), color = 'pvax and elderly'), alpha = 0.5, size = 1.5) +
  geom_line(aes(date, cumsum(pvax_adult), color = 'pvax and adult'), alpha = 0.5, size = 1.5) +
  geom_line(aes(date, cumsum(fvax_elderly), color = 'fvax and elderly'), alpha = 0.5, size = 1.5) +
  geom_line(aes(date, cumsum(fvax_adult), color = 'fvax and adult'), alpha = 0.5, size = 1.5) +
  labs(
    title = 'Death number of the vaccinated',
    x = 'Date',
    y = 'Number'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 2))

Proportion data:

df_deathcount %>%
  ggplot() +
  geom_line(aes(date, cumsum(pvax_elderly)/cumsum(deaths_malaysia$deaths_new_dod), color = 'pvax and elderly'), alpha = 0.5, size = 1.5) +
  geom_line(aes(date, cumsum(pvax_adult)/cumsum(deaths_malaysia$deaths_new_dod), color = 'pvax and adult'), alpha = 0.5, size = 1.5) +
  geom_line(aes(date, cumsum(fvax_elderly)/cumsum(deaths_malaysia$deaths_new_dod), color = 'fvax and elderly'), alpha = 0.5, size = 1.5) +
  geom_line(aes(date, cumsum(fvax_adult)/cumsum(deaths_malaysia$deaths_new_dod), color = 'fvax and adult'), alpha = 0.5, size = 1.5) +
  labs(
    title = 'Death proportion of the vaccinated',
    x = 'Date',
    y = 'Proportion'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 2))

Comorbidities

Comorb and Unvax

Consider comorbidities and reconstruct the data frame.

# comorb and unvax
death_comorb_unvax <- death %>%
  select(-date,-date_positive) %>%
  mutate(dose1=ifelse(!is.na(date_dose1), 1, 0)) %>%
  mutate(dose2=ifelse(!is.na(date_dose2), 1, 0)) %>%
  mutate(dose3=ifelse(!is.na(date_dose3), 1, 0)) %>%
  arrange(date_announced) %>%
  filter(comorb==1 & dose1 ==0 & dose2 ==0 & dose3 ==0)

death_comorb_unvax_c <- death_comorb_unvax %>% # count deaths for comorb
  mutate(date=date_announced) %>%
  select(-date_announced) %>%
  arrange(date) %>%
  group_by(date) %>%
  summarise(count = sum(comorb))

death_comorb_unvax_c <- deaths_malaysia %>%
  select(date) %>%
  left_join(death_comorb_unvax_c, by = 'date') %>%
  mutate(count = ifelse(is.na(count), 0, count))

# uncomorb and unvax
death_uncomorb_unvax <- death %>%
  select(-date,-date_positive) %>%
  mutate(dose1=ifelse(!is.na(date_dose1), 1, 0)) %>%
  mutate(dose2=ifelse(!is.na(date_dose2), 1, 0)) %>%
  mutate(dose3=ifelse(!is.na(date_dose3), 1, 0)) %>%
  arrange(date_announced) %>%
  filter(comorb==0 & dose1 ==0 & dose2 ==0 & dose3 ==0) 

death_uncomorb_unvax_c <- death_uncomorb_unvax %>%
  mutate(date=date_announced) %>%
  select(-date_announced) %>%
  arrange(date) %>%
  group_by(date) %>%
  summarise(count = sum(comorb+1))

death_uncomorb_unvax_c <- deaths_malaysia %>%
  select(date) %>%
  left_join(death_uncomorb_unvax_c, by = 'date') %>%
  mutate(count = ifelse(is.na(count), 0, count))

count_comorb_unvax <- death_comorb_unvax_c %>%
  left_join(death_uncomorb_unvax_c, by = 'date') %>%
  mutate(comorb=count.x, uncomorb=count.y) %>%
  select(-count.x, -count.y)

Cumulative data:

count_comorb_unvax %>%  
  ggplot() +
  geom_line(aes(date, cumsum(comorb), colour = 'unvax and comorb'), size=1.5) +
  geom_line(aes(date, cumsum(uncomorb), colour = 'unvax and uncomorb'), size=1.5, alpha = 1) +
  labs(
    title = 'Death number of (un)comorb',
    x = 'Date',
    y = 'Number'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 2))

Daily data:

count_comorb_unvax %>%  
  ggplot() +
  geom_line(aes(date, comorb, color = 'unvax and comorb'), size=1.5, alpha=0.7) +
  geom_line(aes(date, uncomorb, color = 'unvax and uncomorb'), size=1.5, alpha=0.7) +
  labs(
    title = 'Death numbers of (un)comorb',
    x = 'Date',
    y = 'Number'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 2))

Comorb and Pvax

# comorb and pvax
death_comorb_pvax <- death %>%
  select(-date,-date_positive) %>%
  mutate(dose1=ifelse(!is.na(date_dose1), 1, 0)) %>%
  mutate(dose2=ifelse(!is.na(date_dose2), 1, 0)) %>%
  mutate(dose3=ifelse(!is.na(date_dose3), 1, 0)) %>%
  arrange(date_announced) %>%
  filter(comorb==1 & dose1 ==1 & dose2 ==0 & dose3 ==0)

death_comorb_pvax_c <- death_comorb_pvax %>%
  mutate(date=date_announced) %>%
  select(-date_announced) %>%
  arrange(date) %>%
  group_by(date) %>%
  summarise(count = sum(comorb))

death_comorb_pvax_c <- deaths_malaysia %>%
  select(date) %>%
  left_join(death_comorb_pvax_c, by = 'date') %>%
  mutate(count = ifelse(is.na(count), 0, count))

# uncomorb and pvax
death_uncomorb_pvax <- death %>%
  select(-date,-date_positive) %>%
  mutate(dose1=ifelse(!is.na(date_dose1), 1, 0)) %>%
  mutate(dose2=ifelse(!is.na(date_dose2), 1, 0)) %>%
  mutate(dose3=ifelse(!is.na(date_dose3), 1, 0)) %>%
  arrange(date_announced) %>%
  filter(comorb==0 & dose1 ==1 & dose2 ==0 & dose3 ==0) 

death_uncomorb_pvax_c <- death_uncomorb_pvax %>%
  mutate(date=date_announced) %>%
  select(-date_announced) %>%
  arrange(date) %>%
  group_by(date) %>%
  summarise(count = sum(comorb+1))

death_uncomorb_pvax_c <- deaths_malaysia %>%
  select(date) %>%
  left_join(death_uncomorb_pvax_c, by = 'date') %>%
  mutate(count = ifelse(is.na(count), 0, count))

count_comorb_pvax <- death_comorb_pvax_c %>%
  left_join(death_uncomorb_pvax_c, by = 'date') %>%
  mutate(comorb=count.x, uncomorb=count.y) %>%
  select(-count.x, -count.y)

Cumulative date:

count_comorb_pvax %>%  
  ggplot() +
  geom_line(aes(date, cumsum(comorb), colour = 'pvax and comorb'), size=1.5) +
  geom_line(aes(date, cumsum(uncomorb), colour = 'pvax and uncomorb'), size=1.5, alpha = 1) +
  labs(
    title = 'Death number of (un)comorb',
    x = 'Date',
    y = 'Number'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 2))

Daily data:

count_comorb_pvax %>%  
  ggplot() +
  geom_line(aes(date, comorb, color = 'pvax and comorb'), size=1.5, alpha=0.7) +
  geom_line(aes(date, uncomorb, color = 'pvax and uncomorb'), size=1.5, alpha=0.7) +
  labs(
    title = 'Death numbers of (un)comorb',
    x = 'Date',
    y = 'Number'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 2))

Comorb and Fvax

# comorb and fvax
death_comorb_fvax <- death %>%
  select(-date,-date_positive) %>%
  mutate(dose1=ifelse(!is.na(date_dose1), 1, 0)) %>%
  mutate(dose2=ifelse(!is.na(date_dose2), 1, 0)) %>%
  mutate(dose3=ifelse(!is.na(date_dose3), 1, 0)) %>%
  arrange(date_announced) %>%
  filter(comorb==1 & dose1 ==1 & dose2 ==1 & dose3 ==0)

death_comorb_fvax_c <- death_comorb_fvax %>%
  mutate(date=date_announced) %>%
  select(-date_announced) %>%
  arrange(date) %>%
  group_by(date) %>%
  summarise(count = sum(comorb))

death_comorb_fvax_c <- deaths_malaysia %>%
  select(date) %>%
  left_join(death_comorb_fvax_c, by = 'date') %>%
  mutate(count = ifelse(is.na(count), 0, count))

# uncomorb and fvax
death_uncomorb_fvax <- death %>%
  select(-date,-date_positive) %>%
  mutate(dose1=ifelse(!is.na(date_dose1), 1, 0)) %>%
  mutate(dose2=ifelse(!is.na(date_dose2), 1, 0)) %>%
  mutate(dose3=ifelse(!is.na(date_dose3), 1, 0)) %>%
  arrange(date_announced) %>%
  filter(comorb==0 & dose1 ==1 & dose2 ==1 & dose3 ==0) 

death_uncomorb_fvax_c <- death_uncomorb_fvax %>%
  mutate(date=date_announced) %>%
  select(-date_announced) %>%
  arrange(date) %>%
  group_by(date) %>%
  summarise(count = sum(comorb+1))

death_uncomorb_fvax_c <- deaths_malaysia %>%
  select(date) %>%
  left_join(death_uncomorb_fvax_c, by = 'date') %>%
  mutate(count = ifelse(is.na(count), 0, count))

count_comorb_fvax <- death_comorb_fvax_c %>%
  left_join(death_uncomorb_fvax_c, by = 'date') %>%
  mutate(comorb=count.x, uncomorb=count.y) %>%
  select(-count.x, -count.y)

Cumulative data:

count_comorb_fvax %>%  
  ggplot() +
  geom_line(aes(date, cumsum(comorb), colour = 'fvax and comorb'), size=1.5) +
  geom_line(aes(date, cumsum(uncomorb), colour = 'fvax and uncomorb'), size=1.5, alpha = 1) +
  labs(
    title = 'Death number of un/comorb',
    x = 'Date',
    y = 'Number'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 2))

Daily data:

count_comorb_fvax %>%  
  ggplot() +
  geom_line(aes(date, comorb, colour = 'fvax and comorb'), size=1.5, alpha = 0.5) +
  geom_line(aes(date, uncomorb, colour = 'fvax and uncomorb'), size=1.5, alpha = 0.5) +
  labs(
    title = 'Death number of un/comorb',
    x = 'Date',
    y = 'Number'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 2))

The difference in the number of deaths between comorb and uncomorb was calculated for different vaccination scenarios.

ggplot() +
  geom_line(aes(count_comorb_unvax$date, 
                count_comorb_unvax$comorb-count_comorb_unvax$uncomorb,
                color = 'unvax'), 
            alpha = 0.5,
            size = 1.5) +
  geom_line(aes(count_comorb_pvax$date, 
                count_comorb_pvax$comorb-count_comorb_pvax$uncomorb,
                color = 'pvax'), 
            alpha = 0.5,
            size = 1.5) +
  geom_line(aes(count_comorb_fvax$date, 
                count_comorb_fvax$comorb-count_comorb_fvax$uncomorb,
                color = 'fvax'), 
            alpha = 0.5,
            size = 1.5) +
  labs(
    title = 'Difference between comorb and uncomorb',
    x = 'Date',
    y = 'Number'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 3))

The cumulative difference in the number of deaths between comorb and uncomorb was calculated for different vaccination scenarios.

ggplot() +
  geom_line(aes(count_comorb_unvax$date, 
                cumsum(count_comorb_unvax$comorb)-cumsum(count_comorb_unvax$uncomorb),
                color = 'unvax'), 
            alpha = 0.5,
            size = 1.5) +
  geom_line(aes(count_comorb_pvax$date, 
                cumsum(count_comorb_pvax$comorb)-cumsum(count_comorb_pvax$uncomorb),
                color = 'pvax'), 
            alpha = 0.5,
            size = 1.5) +
  geom_line(aes(count_comorb_fvax$date, 
                cumsum(count_comorb_fvax$comorb)-cumsum(count_comorb_fvax$uncomorb),
                color = 'fvax'), 
            alpha = 0.5,
            size = 1.5) +
  labs(
    title = 'Difference between comorb and uncomorb',
    x = 'Date',
    y = 'Number'
  )+
  theme(
    plot.title = element_text(size = 14, face = "bold"),  
    axis.title.x = element_text(size = 12, face = "bold"),  
    axis.title.y = element_text(size = 12, face = "bold"),  
    axis.text.x = element_text(size = 12, face = "bold"),  
    axis.text.y = element_text(size = 12, face = "bold"),  
    legend.position = "bottom",
    legend.text = element_text(size = 10, face = "bold"),
    legend.title = element_text(size = 12, face = "bold")
  )+
  guides(color = guide_legend(nrow = 3))

Conclusion

The project effectively utilized visualizations to depict the protective effects of vaccination against COVID-19-related mortality in Malaysia. The trends indicated a clear benefit of full vaccination, especially for vulnerable groups like the elderly and those with comorbidities. The analysis highlights the importance of vaccination campaigns and provides a compelling data-driven argument for achieving higher vaccination coverage.