Skip to content

Latest commit

 

History

History
69 lines (50 loc) · 2.62 KB

Fig2a_case_count_tianjin.md

File metadata and controls

69 lines (50 loc) · 2.62 KB
title author output
Singapore figures
Venus Lau; Lauren Tindale
html_document
keep_md
true

#Calculate average duration between exposure, symptom onset, hospitaization, and discharge

data_master <- read.csv("data/COVID-19_Tianjin.csv", header = TRUE,  na.strings=c("","NA"))

data_master$symptom_onset <- as.Date(data_master$symptom_onset, "%d/%m/%Y")
data_master$confirm_date <- as.Date(data_master$confirm_date, "%d/%m/%Y")
data_master$start_source <- as.Date(data_master$start_source, "%d/%m/%Y")
data_master$end_source <- as.Date(data_master$end_source, "%d/%m/%Y")

data_master$days_between_inf_symp = difftime(data_master$symptom_onset, data_master$end_source, units = "days")
data_master$days_between_symp_conf = difftime(data_master$confirm_date, data_master$symptom_onset, units = "days")


mean_sd<-data_master %>% select(days_between_inf_symp:days_between_symp_conf) %>% summarise_all(list(mean=mean, sd=sd), na.rm=TRUE)
cols <- c("Cumulative confirmed"="#440154FF", "Cumulative discharged"="#1F968BFF", "Death per day"="#FDE725FF", "Confirmed per day"="#39568CFF")

p<-data %>%
ggplot() +
  geom_bar(aes(x = date, y=confirmed), fill = "#39568CFF", stat="identity") +
  geom_line(aes(x = date, y = total_confirmed, color = "Cumulative confirmed"), size = 1) +
  geom_bar(aes(x = date, y=deaths), width = 0.5,  fill = "#FDE725FF", stat="identity") +
  geom_line(aes(x = date, y = total_discharge, color = "Cumulative discharged"), size = 1) +

  geom_blank(aes(color = "Confirmed per day")) +
  geom_blank(aes(color = "Death per day")) +
  xlab(label = "Date") +
  ylab(label = "Number of Cases") +
  ggtitle(label = "Tianjin COVID-19 Cases") +
  theme(plot.title = element_text(hjust = 0.5, size=16)) + #centre main title
  theme(axis.text.x = element_text(angle =60, hjust = 1, size = 8),
        axis.title = element_text(size=14),
        axis.ticks.x = element_blank(), #remove x axis ticks
        axis.ticks.y = element_blank(),
        legend.text=element_text(size=12),
        legend.title = element_text(size=14)) + #remove y axis ticks
  scale_x_date(date_breaks = "day") +
  scale_y_continuous(breaks=pretty_breaks(n=20)) +
  scale_colour_manual(name = "Legend", values = cols) +
  theme(panel.background = element_rect(fill = "white"))+
  annotate(geom="text", x=as.Date("2020-02-22"), y=135, label="135", hjust="left") +
  annotate(geom="text", x=as.Date("2020-02-22"), y=65, label="65", hjust="left") 

p

![](Fig2a_case_count_tianjin_files/figure-html/cases by date-1.png)

#ggsave("final_figures/Fig2a_case_count_tianjin.pdf",plot=p, device="pdf",width = 10,height = 7.4,units="in")