#' plot_adjusted_preexisting_rates
#'
#' @param data
#' @param title
#' @param plot_chart
#'
#' @return
#' @export
#'
#' @examples
plot_adjusted_preexisting_rates <- function(data, title = "Exampele", plot_chart = TRUE){
adjusted_comorbididity_rates_select <- adjusted_comorbidity_rates %>%
#dplyr::filter(age_recoded_band == "20-39") %>%
dplyr::select(country, comorbidities, standardised_existing_cond_rate)
# pre_existing_levels <- c(
#
# "diabetes type two" = "diabetes_type_two",
# "diabetes type one" = "diabetes_type_one",
# "heart disease" = "heart_disease",
# "lung condidition" = "lung_condition",
# "liver disease" = "liver_disease",
# "kidney disease" = "kidney_disease"
#
# )
#
#
# adj_comorb_forcats <- adjusted_comorbididity_rates_select %>%
# dplyr::mutate("Pre-existing conditions" = forcats::fct_recode("Pre-existing conditions", !!!pre_existing_levels))
cbbPalette <- c("#000000", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7", "#CC6600")
title <- "Adjusted rates for top 5 countries"
plot_adjusted_rates <- ggplot2::ggplot(adjusted_comorbididity_rates_select,
ggplot2::aes(comorbidities, standardised_existing_cond_rate, country)) +
ggplot2::coord_flip() +
ggplot2::geom_bar(ggplot2::aes(fill = country), width = 0.4,
position = position_dodge(width = 0.5), stat = "identity") +
ggplot2::scale_fill_manual(values = cbbPalette) +
ggplot2::labs(title = title,
subtitle = "\nNote: Adjusted rates for pre-existing conditions in %",
x = "Pre-existing conditions", y = "Percentage", caption = "Source: Your.md Data") +
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 = 12, face = "bold"),
plot.subtitle = ggplot2::element_text(size = 10),
legend.position = "bottom" , legend.box = "horizontal") +
ggplot2::theme_bw()
plot_adjusted_rates
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.