knitr::opts_chunk$set( collapse = TRUE, comment = "#>", echo = FALSE, warning = FALSE, message = FALSE ) library(magrittr) library(tidyverse)
data_bar_charts <- read_csv("/Users/gabrielburcea/rprojects/data/your.md/cleaned_data_22092020.csv") country_levels <- c("United Kingdom" = "Great Britain", "USA" = "United States of America") data_bar_charts <- data_bar_charts %>% dplyr::mutate(country = forcats::fct_recode(country, !!!country_levels)) # get only covid positive and showing symptoms for the purpose of analysis of symptoms reported by comorbidity # double check data_covid_exp <- data_bar_charts %>% dplyr::filter(covid_tested != "negative")
count_country <- data_bar_charts %>% dplyr::select(id, country) %>% dplyr::group_by(country) %>% tally() %>% dplyr::mutate(Percent = n/sum(n)*100) %>% dplyr::arrange(desc(n)) count_country
obesity_data <- data_covid_exp %>% dplyr::select(id, obesity, chills, cough, diarrhoea, headache, loss_smell_taste, muscle_ache, nasal_congestion, nausea_vomiting, shortness_breath, sore_throat, sputum, temperature, loss_appetite, chest_pain, itchy_eyes, joint_pain) %>% tidyr::drop_na() obesity_count <- obesity_data %>% dplyr::filter(obesity == "Yes") %>% tidyr::pivot_longer(cols = 3:18, names_to = "symptoms", values_to = "yes_no") %>% dplyr::filter(yes_no == "Yes") %>% group_by(symptoms) %>% dplyr::tally() %>% dplyr::mutate(Percentage = n/sum(n)) %>% dplyr::arrange(desc(n)) start_date = as.Date("2020-04-09", tz = "Europe/London") end_date = as.Date("2020-08-18") title_stub <- "SARS-Covid-19 Symptoms by Obesity\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_obesity_sympt <- ggplot2::ggplot(obesity_count, ggplot2::aes(x = reorder(symptoms, - Percentage), 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_minimal() + ggplot2::labs( title = chart_title, subtitle = "Counts of symptoms reported by obesity\nNotes: i) includes responders with both Covid-19 tested positive and those showing symptoms", y = "Counts", x = "Symptoms", caption = "Source: Your.md Dataset") + 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), axis.text.x = ggplot2::element_text(angle = 55, hjust = 1) ) plot_obesity_sympt
asthma_data <- data_covid_exp %>% dplyr::select(id, asthma, chills, cough, diarrhoea, headache, loss_smell_taste, muscle_ache, nasal_congestion, nausea_vomiting, shortness_breath, sore_throat, sputum, temperature, loss_appetite, chest_pain, itchy_eyes, joint_pain) %>% tidyr::drop_na()
asthma_count <- asthma_data %>% tidyr::pivot_longer(cols = 3:18, names_to = "symptoms", values_to = "yes_no") %>% dplyr::filter(asthma == "Yes" & yes_no == "Yes") %>% dplyr::group_by(symptoms) %>% dplyr::tally() %>% dplyr::mutate(Percentage = n/sum(n)) %>% dplyr::arrange(desc(n)) start_date = as.Date("2020-04-09", tz = "Europe/London") end_date = as.Date("2020-08-18") title_stub <- "Asthma across symptoms\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_asthma_sympt <- ggplot2::ggplot(asthma_count, ggplot2::aes(x = reorder(symptoms, - Percentage), 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(asthma_count$symptoms)) + #ggplot2::theme(legend.position = "bottom") + #ggplot2::guides(fill = ggplot2::guide_legend(nrow = 3)) + ggplot2::theme_minimal() + ggplot2::labs( title = chart_title, subtitle = "Counts of symptoms reported by asthma\nNotes: i) includes responders with both Covid-19 tested positive and those showing symptoms", y = "Counts", x = "Symptoms", caption = "Source: Dataset - Your.md Dataset") + 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), axis.text.x = ggplot2::element_text(angle = 55, hjust = 1) ) plot_asthma_sympt
diabetes_type_one_data <- data_covid_exp %>% dplyr::select(id, diabetes_type_one, chills, cough, diarrhoea, headache, loss_smell_taste, muscle_ache, nasal_congestion, nausea_vomiting, shortness_breath, sore_throat, sputum, temperature, loss_appetite, chest_pain, itchy_eyes, joint_pain)
diabetes_count <- diabetes_type_one_data %>% tidyr::pivot_longer(cols = 3:18, names_to = "symptoms", values_to = "yes_no") %>% dplyr::filter(diabetes_type_one == "Yes" & yes_no == "Yes") %>% dplyr::group_by(symptoms) %>% dplyr::tally() %>% dplyr::mutate(Percentage = n/sum(n)) %>% dplyr::arrange(desc(n)) start_date = as.Date("2020-04-09", tz = "Europe/London") end_date = as.Date("2020-08-18") title_stub <- "SARS-Covid-19 Symptoms by Diabetes type I\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_diabetes_sympt <- ggplot2::ggplot(diabetes_count, ggplot2::aes(x = reorder(symptoms,- Percentage), 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(diabetes_count$symptoms)) + #ggplot2::theme(legend.position = "bottom") + #ggplot2::guides(fill = ggplot2::guide_legend(nrow = 3)) + ggplot2::theme_minimal() + ggplot2::labs( title = chart_title, subtitle = "SARS-Covid-19 Symptoms by Diabetes type one\nNotes: i) includes responders with both Covid-19 tested positive and those showing symptoms", y = "Counts", x = "Symptoms", caption = "Source: Dataset - Your.md Dataset") + 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), axis.text.x = ggplot2::element_text(angle = 55, hjust = 1) ) plot_diabetes_sympt
diabetes_type_two_data <- data_covid_exp %>% dplyr::select(id, diabetes_type_two, chills, cough, diarrhoea, headache, loss_smell_taste, muscle_ache, nasal_congestion, nausea_vomiting, shortness_breath, sore_throat, sputum, temperature, loss_appetite, chest_pain, itchy_eyes, joint_pain)
diabetes_two_count <- diabetes_type_two_data %>% tidyr::pivot_longer(cols = 3:18, names_to = "symptoms", values_to = "yes_no") %>% dplyr::filter(diabetes_type_two == "Yes" & yes_no == "Yes") %>% dplyr::group_by(symptoms) %>% dplyr::tally() %>% dplyr::mutate(Percentage = n/sum(n)) %>% dplyr::arrange(desc(n)) start_date = as.Date("2020-04-09", tz = "Europe/London") end_date = as.Date("2020-08-18") title_stub <- "SARS-Covid-19 Symptoms by Diabetes type II\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_diabetes2_sympt <- ggplot2::ggplot(diabetes_two_count, ggplot2::aes(x = reorder(symptoms,- Percentage), 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(diabetes_count$symptoms)) + #ggplot2::theme(legend.position = "bottom") + #ggplot2::guides(fill = ggplot2::guide_legend(nrow = 3)) + ggplot2::theme_minimal() + ggplot2::labs( title = chart_title, subtitle = "SARS-Covid-19 Symptoms by Diabetes type II\nNotes: i) includes responders with both Covid-19 tested positive and those showing symptoms", y = "Counts", x = "Symptoms", caption = "Source: Dataset - Your.md Dataset") + 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), axis.text.x = ggplot2::element_text(angle = 55, hjust = 1) ) plot_diabetes2_sympt
heart_data <- data_covid_exp %>% dplyr::select(id, heart_disease, chills, cough, diarrhoea, headache, loss_smell_taste, muscle_ache, nasal_congestion, nausea_vomiting, shortness_breath, sore_throat, sputum, temperature, loss_appetite, chest_pain, itchy_eyes, joint_pain)
heart_count <- heart_data %>% tidyr::pivot_longer(cols = 3:18, names_to = "symptoms", values_to = "yes_no") %>% dplyr::filter(heart_disease == "Yes" & yes_no == "Yes") %>% dplyr::group_by(symptoms) %>% dplyr::tally() %>% dplyr::mutate(Percentage = n/sum(n)) %>% dplyr::arrange(desc(n)) start_date = as.Date("2020-04-09", tz = "Europe/London") end_date = as.Date("2020-08-18") title_stub <- "SARS-Covid-19 Symptoms by Heart disease \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_asthma_sympt <- ggplot2::ggplot(heart_count, ggplot2::aes(x = reorder(symptoms, - Percentage), 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(heart_count$symptoms)) + #ggplot2::theme(legend.position = "bottom") + #ggplot2::guides(fill = ggplot2::guide_legend(nrow = 3)) + ggplot2::theme_minimal() + ggplot2::labs( title = chart_title, subtitle = "Counts of symptoms reported by heart disease\nNotes: i) includes responders with both Covid-19 tested positive and those showing symptoms", y = "Counts", x = "Symptoms", caption = "Source: Dataset - Your.md Dataset") + 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), axis.text.x = ggplot2::element_text(angle = 55, hjust = 1) ) plot_asthma_sympt
hypertension_data <- data_covid_exp %>% dplyr::select(id, hypertension, chills, cough, diarrhoea, headache, loss_smell_taste, muscle_ache, nasal_congestion, nausea_vomiting, shortness_breath, sore_throat, sputum, temperature, loss_appetite, chest_pain, itchy_eyes, joint_pain)
hypertension_count <- hypertension_data %>% tidyr::pivot_longer(cols = 3:18, names_to = "symptoms", values_to = "yes_no") %>% dplyr::filter(hypertension == "Yes" & yes_no == "Yes") %>% dplyr::group_by(symptoms) %>% dplyr::tally() %>% dplyr::mutate(Percentage = n/sum(n)) %>% dplyr::arrange(desc(n)) start_date = as.Date("2020-04-09", tz = "Europe/London") end_date = as.Date("2020-08-18") title_stub <- "SARS-Covid-19 Symptoms by Hypertension \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_hypertension_sympt <- ggplot2::ggplot(hypertension_count, ggplot2::aes(x = reorder(symptoms, - Percentage), 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(hypertension_count$symptoms)) + #ggplot2::theme(legend.position = "bottom") + #ggplot2::guides(fill = ggplot2::guide_legend(nrow = 3)) + ggplot2::theme_minimal() + ggplot2::labs( title = chart_title, subtitle = "Counts of symptoms reported by Hypertension \nNotes: i) includes responders with both Covid-19 tested positive and those showing symptoms", y = "Counts", x = "Symptoms", caption = "Source: Dataset - Your.md Dataset") + 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), axis.text.x = ggplot2::element_text(angle = 55, hjust = 1) ) plot_hypertension_sympt
liver_data <- data_covid_exp %>% dplyr::select(id,liver_disease, chills, cough, diarrhoea, headache, loss_smell_taste, muscle_ache, nasal_congestion, nausea_vomiting, shortness_breath, sore_throat, sputum, temperature, loss_appetite, chest_pain, itchy_eyes, joint_pain)
liver_count <- liver_data %>% tidyr::pivot_longer(cols = 3:18, names_to = "symptoms", values_to = "yes_no") %>% dplyr::filter(liver_disease == "Yes" & yes_no == "Yes") %>% dplyr::group_by(symptoms) %>% dplyr::tally() %>% dplyr::mutate(Percentage = n/sum(n)) %>% dplyr::arrange(desc(n)) start_date = as.Date("2020-04-09", tz = "Europe/London") end_date = as.Date("2020-08-18") title_stub <- "SARS-Covid-19 Symptoms by Liver disease \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_liver_sympt <- ggplot2::ggplot(liver_count, ggplot2::aes(x = reorder(symptoms, - Percentage), 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(liver_count$symptoms)) + #ggplot2::theme(legend.position = "bottom") + #ggplot2::guides(fill = ggplot2::guide_legend(nrow = 3)) + ggplot2::theme_minimal() + ggplot2::labs( title = chart_title, subtitle = "Counts of symptoms reported by liver disease \nNotes: i) includes responders with both Covid-19 tested positive and those showing symptoms", y = "Counts", x = "Symptoms", caption = "Source: Dataset - Your.md Dataset") + 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), axis.text.x = ggplot2::element_text(angle = 55, hjust = 1) ) plot_liver_sympt ```` ```r lung_condition_data <- data_covid_exp %>% dplyr::select(id, lung_condition, chills, cough, diarrhoea, headache, loss_smell_taste, muscle_ache, nasal_congestion, nausea_vomiting, shortness_breath, sore_throat, sputum, temperature, joint_pain, chest_pain, itchy_eyes, loss_appetite) %>% tidyr::drop_na()
lung_count <- lung_condition_data %>% tidyr::pivot_longer(cols = 3:18, names_to = "symptoms", values_to = "yes_no") %>% dplyr::filter(lung_condition== "Yes" & yes_no == "Yes") %>% dplyr::group_by(symptoms) %>% dplyr::tally() %>% dplyr::mutate(Percentage = n/sum(n)) %>% dplyr::arrange(desc(n)) start_date = as.Date("2020-04-09", tz = "Europe/London") end_date = as.Date("2020-08-18") title_stub <- "SARS-Covid-19 Symptoms by Lung disease \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_lung_sympt <- ggplot2::ggplot(lung_count, ggplot2::aes(x = reorder(symptoms, - Percentage), 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(lung_count$symptoms)) + #ggplot2::theme(legend.position = "bottom") + #ggplot2::guides(fill = ggplot2::guide_legend(nrow = 3)) + ggplot2::theme_minimal() + ggplot2::labs( title = chart_title, subtitle = "Counts of symptoms reported by lung disease \nNotes: i) includes responders with both Covid-19 tested positive and those showing symptoms", y = "Counts", x = "Symptoms", caption = "Source: Dataset - Your.md Dataset") + 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), axis.text.x = ggplot2::element_text(angle = 55, hjust = 1) ) plot_lung_sympt
kidney_data <- data_covid_exp %>% dplyr::select(id, kidney_disease, chills, cough, diarrhoea, headache, loss_smell_taste, muscle_ache, nasal_congestion, nausea_vomiting, shortness_breath, sore_throat, sputum, temperature, chest_pain, joint_pain, loss_appetite, itchy_eyes) %>% tidyr::drop_na()
kidney_count <- kidney_data %>% tidyr::pivot_longer(cols = 3:18, names_to = "symptoms", values_to = "yes_no") %>% dplyr::filter(kidney_disease == "Yes" & yes_no == "Yes") %>% dplyr::group_by(symptoms) %>% dplyr::tally() %>% dplyr::mutate(Percentage = n/sum(n)) %>% dplyr::arrange(desc(n)) start_date = as.Date("2020-04-09", tz = "Europe/London") end_date = as.Date("2020-08-18") title_stub <- "SARS-Covid-19 Symptoms by Kidney disease \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_kidney_sympt <- ggplot2::ggplot(kidney_count, ggplot2::aes(x = reorder(symptoms, - Percentage), 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(kidney_count$symptoms)) + #ggplot2::theme(legend.position = "bottom") + #ggplot2::guides(fill = ggplot2::guide_legend(nrow = 3)) + ggplot2::theme_minimal() + ggplot2::labs( title = chart_title, subtitle = "Counts of symptoms reported by kidney disease\nNotes: i) includes responders with both Covid-19 tested positive and those showing symptoms", y = "Counts", x = "Symptoms", caption = "Source: Dataset - Your.md Dataset") + 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), axis.text.x = ggplot2::element_text(angle = 55, hjust = 1) ) plot_kidney_sympt
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.