My Github Pages
by Yeung Ka Ming, CFA
COVID-19 Cumulative Deaths for selected countries
library(ggplot2)
library(tidyverse)
Download data from WHO website
covid.data <- read.csv("WHO-COVID-19-global-data.csv", header = TRUE, sep = ",", encoding ="UTF-8")
# rename date column header
colnames(covid.data)[1] <- "Date_reported"
# change data frame to tibble and specify date column as Date format
covid.data.tbl <- as_tibble(covid.data) %>%
mutate(Date_reported = as.Date(Date_reported))
# pick Singapore and China and make tibble "long"
covid.data.tbl1 <- covid.data.tbl %>%
filter(Country == "Singapore" | Country == "China" ) %>%
pivot_longer("Cumulative_deaths",
names_to = "Cumulative_deaths_key",
values_to = "Cumulative_deaths_value") %>%
filter(Cumulative_deaths_value > 0)
# plot graph
p <- ggplot(covid.data.tbl1, aes(x = Date_reported,
y = Cumulative_deaths_value, color=Country))
p + geom_line() +
ggtitle("COVID-19 Cumulative Deaths") +
ylab("Cumulative Deaths") +
xlab("Date")