data <- read_csv("/Users/gabrielburcea/rprojects/data/your.md/cleaned_data_22092020.csv")
data_select <- data %>% 
  dplyr::select(id, covid_tested, age_band,  chills, cough, diarrhoea, fatigue, headache, muscle_ache, nasal_congestion, 
                nausea_vomiting, shortness_breath, sore_throat, sputum, loss_appetite, chest_pain)
pivot_table <- data_select %>%
  tidyr::pivot_longer(cols = 4:16, names_to = "symptoms", values_to = "yes_no")

Covid-19 positive tested in group age 20-39

count_20_39_pos <- pivot_table %>%
  drop_na() %>%
  filter(age_band == "20-39" & covid_tested == "positive") %>% 
  dplyr::group_by(symptoms, yes_no) %>%
  tally() %>%
  dplyr::mutate(percent = n/sum(n)*100) %>%
  dplyr::filter(yes_no != "No") %>%
  arrange(desc(n))


start_date = as.Date("2020-04-19") 
end_date = as.Date("2020-09-01")

title_stub <- "SARS-Covid-19 positive in 20-39 age group category\n"
start_date_title <- format(as.Date(start_date), format = "%d %B %Y")
end_date_title <- format(as.Date(end_date), format = "%d %B %Y")
chart_title <- paste0(title_stub, start_date_title, " to ", end_date_title)

plot_count_20_30 <- 
  ggplot2::ggplot(count_20_39_pos, ggplot2::aes(x = reorder(symptoms, - n), y = n, fill = n)) +
  ggplot2::coord_flip() +
  ggplot2::geom_bar(stat = "identity", position = "dodge") +
  ggplot2::scale_fill_viridis_c(option = "magma", direction = -1) +
  ggplot2::theme_bw() +
  ggplot2::labs(title = chart_title,
                  subtitle = "Symptoms in 20-39 age group that tested positive",
                  y = "Percent", x = "Symptoms", caption = "Source: Your.md Dataset, Global Digital Health") +
  ggplot2::theme(axis.title.y = ggplot2::element_text(margin = ggplot2::margin(t = 0, r = 21, b = 0, l = 0)),
                   plot.title = ggplot2::element_text(size = 10, face = "bold"),
                   plot.subtitle = ggplot2::element_text(size = 9),
                   legend.position = "bottom", legend.box = "horizontal",
                   axis.text.x = ggplot2::element_text(angle = 55, hjust = 1))


plot_count_20_30

Covid-19 positive tested in group age 20-39

knitr::kable(count_20_39_pos)

Covid-19 showing symptoms in group age 20-39

count_20_39_show_sympt <- pivot_table %>%
  drop_na() %>%
  filter(age_band == "20-39" & covid_tested == "showing symptoms") %>% 
  dplyr::group_by(symptoms, yes_no) %>%
  tally() %>%
  dplyr::mutate(percent = n/sum(n)*100) %>%
  dplyr::filter(yes_no != "No") %>%
  arrange(desc(n))


start_date = as.Date("2020-04-19") 
end_date = as.Date("2020-09-01")

title_stub <- "SARS-Covid-19 showing symptoms in 20-39 age group category\n"
start_date_title <- format(as.Date(start_date), format = "%d %B %Y")
end_date_title <- format(as.Date(end_date), format = "%d %B %Y")
chart_title <- paste0(title_stub, start_date_title, " to ", end_date_title)

plot_count_20_30 <- 
  ggplot2::ggplot(count_20_39_show_sympt, ggplot2::aes(x = reorder(symptoms, - n), y = n, fill = n)) +
  ggplot2::coord_flip() +
  ggplot2::geom_bar(stat = "identity", position = "dodge") +
  ggplot2::scale_fill_viridis_c(option = "magma", direction = -1) +
  #ggplot2::scale_x_discrete(limits = unique(obesity_count$symptoms)) +
  #ggplot2::theme(legend.position = "bottom") +
  #ggplot2::guides(fill = ggplot2::guide_legend(nrow = 3)) +
  ggplot2::theme_bw() +
  ggplot2::labs(title = chart_title,
                  subtitle = "Symptoms in 20-39 age group showing Covid-19 symptoms",
                  y = "Percent", x = "Symptoms", caption = "Source: Your.md Dataset, Global Digital Health") +
  ggplot2::theme(axis.title.y = ggplot2::element_text(margin = ggplot2::margin(t = 0, r = 21, b = 0, l = 0)),
                   plot.title = ggplot2::element_text(size = 10, face = "bold"),
                   plot.subtitle = ggplot2::element_text(size = 9),
                   legend.position = "bottom", legend.box = "horizontal",
                   axis.text.x = ggplot2::element_text(angle = 55, hjust = 1))


plot_count_20_30

Covid-19 showing symptoms in group age 20-39

knitr::kable(count_20_39_show_sympt)

Covid-19 positive in group age 40-59

count_40_59_pos <- pivot_table %>%
  drop_na() %>%
  filter(age_band == "40-59" & covid_tested == "positive") %>% 
  dplyr::group_by(symptoms, yes_no) %>%
  tally() %>%
  dplyr::mutate(percent = n/sum(n)*100) %>%
  dplyr::filter(yes_no != "No") %>%
  arrange(desc(n))

start_date = as.Date("2020-04-19") 
end_date = as.Date("2020-09-01")

title_stub <- "SARS-Covid-19 positive in 40-59 age group category\n"
start_date_title <- format(as.Date(start_date), format = "%d %B %Y")
end_date_title <- format(as.Date(end_date), format = "%d %B %Y")
chart_title <- paste0(title_stub, start_date_title, " to ", end_date_title)

plot_count_40_59 <- 
  ggplot2::ggplot(count_40_59_pos, ggplot2::aes(x = reorder(symptoms, - n), y = n, fill = n)) +
  ggplot2::coord_flip() +
  ggplot2::geom_bar(stat = "identity", position = "dodge") +
  ggplot2::scale_fill_viridis_c(option = "magma", direction = -1) +
  ggplot2::theme_bw() +
  ggplot2::labs(title = chart_title,
                  subtitle = "Symptoms in 40-59 age group that tested positive",
                  y = "Percent", x = "Symptoms", caption = "Source: Your.md Dataset, Global Digital Health") +
  ggplot2::theme(axis.title.y = ggplot2::element_text(margin = ggplot2::margin(t = 0, r = 21, b = 0, l = 0)),
                   plot.title = ggplot2::element_text(size = 10, face = "bold"),
                   plot.subtitle = ggplot2::element_text(size = 9),
                   legend.position = "bottom", legend.box = "horizontal",
                   axis.text.x = ggplot2::element_text(angle = 55, hjust = 1))


plot_count_40_59

Covid-19 positive in group age 40-59

knitr::kable(count_40_59_pos)

Covid-19 showing symptoms in group age 40-59

count_40_59_showing_symptoms <- pivot_table %>%
  drop_na() %>%
  filter(age_band == "40-59" & covid_tested == "showing symptoms") %>% 
  dplyr::group_by(symptoms, yes_no) %>%
  tally() %>%
  dplyr::mutate(percent = n/sum(n)*100) %>%
  dplyr::filter(yes_no != "No") %>%
  arrange(desc(n))


start_date = as.Date("2020-04-19") 
end_date = as.Date("2020-09-01")

title_stub <- "SARS-Covid-19 showing symptoms in 40-59 age group category\n"
start_date_title <- format(as.Date(start_date), format = "%d %B %Y")
end_date_title <- format(as.Date(end_date), format = "%d %B %Y")
chart_title <- paste0(title_stub, start_date_title, " to ", end_date_title)

plot_count_40_59 <- 
  ggplot2::ggplot(count_40_59_showing_symptoms , ggplot2::aes(x = reorder(symptoms, - n), y = n, fill = n)) +
  ggplot2::coord_flip() +
  ggplot2::geom_bar(stat = "identity", position = "dodge") +
  ggplot2::scale_fill_viridis_c(option = "magma", direction = -1) +
  ggplot2::theme_bw() +
  ggplot2::labs(title = chart_title,
                  subtitle = "Symptoms in 40-59 age group that tested positive",
                  y = "Percent", x = "Symptoms", caption = "Source: Your.md Dataset, Global Digital Health") +
  ggplot2::theme(axis.title.y = ggplot2::element_text(margin = ggplot2::margin(t = 0, r = 21, b = 0, l = 0)),
                   plot.title = ggplot2::element_text(size = 10, face = "bold"),
                   plot.subtitle = ggplot2::element_text(size = 9),
                   legend.position = "bottom", legend.box = "horizontal",
                   axis.text.x = ggplot2::element_text(angle = 55, hjust = 1))


plot_count_40_59

Covid-19 showing symptoms in group age 40-59

knitr::kable(count_40_59_showing_symptoms)

Covid-19 positive in group age 60+

count_60_plus_pos <- pivot_table %>%
  drop_na() %>%
  filter(age_band == "60+" & covid_tested == "positive") %>% 
  dplyr::group_by(symptoms, yes_no) %>%
  tally() %>%
  dplyr::mutate(percent = n/sum(n)*100) %>%
  dplyr::filter(yes_no != "No") %>%
  arrange(desc(n))


start_date = as.Date("2020-04-19") 
end_date = as.Date("2020-09-01")

title_stub <- "SARS-Covid-19 positive in 60 + age group category\n"
start_date_title <- format(as.Date(start_date), format = "%d %B %Y")
end_date_title <- format(as.Date(end_date), format = "%d %B %Y")
chart_title <- paste0(title_stub, start_date_title, " to ", end_date_title)

plot_count_60_plus <- 
  ggplot2::ggplot(count_60_plus_pos, ggplot2::aes(x = reorder(symptoms, - n), y = n, fill = n)) +
  ggplot2::coord_flip() +
  ggplot2::geom_bar(stat = "identity", position = "dodge") +
  ggplot2::scale_fill_viridis_c(option = "magma", direction = -1) +
  ggplot2::theme_bw() +
  ggplot2::labs(title = chart_title,
                  subtitle = "Symptoms in 60+ age group that tested positive",
                  y = "Percent", x = "Symptoms", caption = "Source: Your.md Dataset, Global Digital Health") +
  ggplot2::theme(axis.title.y = ggplot2::element_text(margin = ggplot2::margin(t = 0, r = 21, b = 0, l = 0)),
                   plot.title = ggplot2::element_text(size = 10, face = "bold"),
                   plot.subtitle = ggplot2::element_text(size = 9),
                   legend.position = "bottom", legend.box = "horizontal",
                   axis.text.x = ggplot2::element_text(angle = 55, hjust = 1))


plot_count_60_plus

Covid-19 positive in group age 60+

knitr::kable(count_60_plus_pos)

Covid-19 showing symptoms in group age 60+

count_60_plus_showing_symptoms <- pivot_table %>%
  drop_na() %>%
  filter(age_band == "60+" & covid_tested == "showing symptoms") %>% 
  dplyr::group_by(symptoms, yes_no) %>%
  tally() %>%
  dplyr::mutate(percent = n/sum(n)*100) %>%
  dplyr::filter(yes_no != "No") %>%
  arrange(desc(n))


start_date = as.Date("2020-04-19") 
end_date = as.Date("2020-09-01")

title_stub <- "SARS-Covid-19 showing symptoms in 60 + age group category\n"
start_date_title <- format(as.Date(start_date), format = "%d %B %Y")
end_date_title <- format(as.Date(end_date), format = "%d %B %Y")
chart_title <- paste0(title_stub, start_date_title, " to ", end_date_title)

plot_count_60_plus_show <- 
  ggplot2::ggplot(count_60_plus_showing_symptoms, ggplot2::aes(x = reorder(symptoms, - n), y = n, fill = n)) +
  ggplot2::coord_flip() +
  ggplot2::geom_bar(stat = "identity", position = "dodge") +
  ggplot2::scale_fill_viridis_c(option = "magma", direction = -1) +
  ggplot2::theme_bw() +
  ggplot2::labs(title = chart_title,
                  subtitle = "Symptoms in 60+ age group that tested positive",
                  y = "Percent", x = "Symptoms", caption = "Source: Your.md Dataset, Global Digital Health") +
  ggplot2::theme(axis.title.y = ggplot2::element_text(margin = ggplot2::margin(t = 0, r = 21, b = 0, l = 0)),
                   plot.title = ggplot2::element_text(size = 10, face = "bold"),
                   plot.subtitle = ggplot2::element_text(size = 9),
                   legend.position = "bottom", legend.box = "horizontal",
                   axis.text.x = ggplot2::element_text(angle = 55, hjust = 1))


plot_count_60_plus_show

Covid-19 showing symptoms in group age 60+

knitr::kable(count_60_plus_showing_symptoms)


gabrielburcea/cvindia documentation built on Feb. 17, 2021, 3:31 a.m.