location_levels=c("Jordan", "Global")
ds1<- read.csv("IHME-GBD_2021_DATA-5df25752-1_class1.csv")
ds2<- read.csv("IHME-GBD_2021_DATA-878c1bf3-1_class2.csv")
sapply(ds2, class)
## measure location sex age cause metric
## "character" "character" "character" "character" "character" "character"
## year val upper lower
## "integer" "numeric" "numeric" "numeric"
unique(ds1[, 5])
## [1] "Communicable, maternal, neonatal, and nutritional diseases"
## [2] "Non-communicable diseases"
## [3] "Injuries"
## [4] "Other COVID-19 pandemic-related outcomes"
lapply(ds2[, -c(8, 9, 10)], unique)
## $measure
## [1] "Deaths"
## [2] "DALYs (Disability-Adjusted Life Years)"
## [3] "YLDs (Years Lived with Disability)"
## [4] "YLLs (Years of Life Lost)"
## [5] "Prevalence"
##
## $location
## [1] "Global" "Jordan"
##
## $sex
## [1] "Male" "Female" "Both"
##
## $age
## [1] "<5 years" "5-9 years" "10-14 years" "15-19 years" "20-24 years"
## [6] "25-29 years" "All ages" "0-14 years"
##
## $cause
## [1] "Neglected tropical diseases and malaria"
## [2] "Chronic respiratory diseases"
## [3] "Transport injuries"
## [4] "Neoplasms"
## [5] "Unintentional injuries"
## [6] "Mental disorders"
## [7] "Nutritional deficiencies"
## [8] "Digestive diseases"
## [9] "Cardiovascular diseases"
## [10] "Musculoskeletal disorders"
## [11] "Other non-communicable diseases"
## [12] "Neurological disorders"
## [13] "Self-harm and interpersonal violence"
## [14] "Skin and subcutaneous diseases"
## [15] "Respiratory infections and tuberculosis"
## [16] "Enteric infections"
## [17] "Other infectious diseases"
## [18] "Maternal and neonatal disorders"
## [19] "Substance use disorders"
## [20] "Diabetes and kidney diseases"
## [21] "HIV/AIDS and sexually transmitted infections"
## [22] "Sense organ diseases"
##
## $metric
## [1] "Number" "Percent" "Rate"
##
## $year
## [1] 1980 1990 2010 2000 2021 2020
#Tables and figures
children<- c("<5 years" ,"5-9 years","10-14 years")
measures<- c("Deaths", "DALYs (Disability-Adjusted Life Years)", "YLDs (Years Lived with Disability)" )
ds1 %>%
filter(year==2021, age =="0-14 years" , location=="Jordan", metric=="Rate", measure %in% measures ) %>%
mutate(val=paste(round(val, 2), "(UI:", round(lower, 2), "-", round(upper, 2), ")")) %>%
select(sex, cause, measure, val) %>%
tidyr::spread(measure, val) %>%
arrange( cause, sex) %>%
gt()
| sex | cause | DALYs (Disability-Adjusted Life Years) | Deaths | YLDs (Years Lived with Disability) |
|---|---|---|---|---|
| Both | Communicable, maternal, neonatal, and nutritional diseases | 4668.44 (UI: 3994.4 - 5567.48 ) | 39.61 (UI: 32.96 - 47.73 ) | 1137.25 (UI: 802.26 - 1566.36 ) |
| Female | Communicable, maternal, neonatal, and nutritional diseases | 4388.72 (UI: 3707.02 - 5199.88 ) | 35.46 (UI: 29.29 - 42.27 ) | 1228.25 (UI: 859.55 - 1759.7 ) |
| Male | Communicable, maternal, neonatal, and nutritional diseases | 4933.04 (UI: 4093.15 - 5935.8 ) | 43.55 (UI: 35.17 - 53.37 ) | 1051.17 (UI: 728.62 - 1473.27 ) |
| Both | Injuries | 1033.4 (UI: 887.04 - 1216.3 ) | 11.12 (UI: 9.41 - 13.32 ) | 109.54 (UI: 79.07 - 148.26 ) |
| Female | Injuries | 781.65 (UI: 667.25 - 926.03 ) | 7.96 (UI: 6.64 - 9.51 ) | 111.01 (UI: 78.3 - 150.04 ) |
| Male | Injuries | 1271.54 (UI: 1074.5 - 1534.13 ) | 14.11 (UI: 11.8 - 17.11 ) | 108.15 (UI: 76.87 - 148.09 ) |
| Both | Non-communicable diseases | 6064.51 (UI: 5031.98 - 7301.76 ) | 35.49 (UI: 29.26 - 44.31 ) | 2967.17 (UI: 2125.72 - 4037.57 ) |
| Female | Non-communicable diseases | 6000.08 (UI: 4977.35 - 7270.26 ) | 33.11 (UI: 27.73 - 40.03 ) | 3104.89 (UI: 2219.53 - 4259.35 ) |
| Male | Non-communicable diseases | 6125.45 (UI: 5001.11 - 7520.75 ) | 37.74 (UI: 29.78 - 48.35 ) | 2836.9 (UI: 2029.19 - 3864.67 ) |
| Both | Other COVID-19 pandemic-related outcomes | 46.15 (UI: 0 - 168.12 ) | 0.55 (UI: 0 - 1.93 ) | NA |
| Female | Other COVID-19 pandemic-related outcomes | 34.79 (UI: 0 - 159.77 ) | 0.39 (UI: 0 - 1.8 ) | NA |
| Male | Other COVID-19 pandemic-related outcomes | 56.9 (UI: 0 - 184.06 ) | 0.69 (UI: 0 - 2.21 ) | NA |
children<- c("<5 years" ,"5-9 years","10-14 years")
measures<- c("Deaths", "DALYs (Disability-Adjusted Life Years)", "YLDs (Years Lived with Disability)" )
ds2 %>%
filter(year==2021, age =="0-14 years" , location=="Jordan", metric=="Rate", measure %in% measures ) %>%
mutate(val=paste(round(val, 2), "(UI:", round(lower, 2), "-", round(upper, 2), ")")) %>%
select(sex, cause, measure, val) %>%
tidyr::spread(measure, val) %>%
arrange( cause, sex) %>%
gt()
| sex | cause | DALYs (Disability-Adjusted Life Years) | Deaths | YLDs (Years Lived with Disability) |
|---|---|---|---|---|
| Both | Cardiovascular diseases | 272.56 (UI: 228.81 - 321.33 ) | 2.7 (UI: 2.22 - 3.31 ) | 42.28 (UI: 29.01 - 60.05 ) |
| Female | Cardiovascular diseases | 241.56 (UI: 200.55 - 289.51 ) | 2.32 (UI: 1.87 - 2.89 ) | 42.41 (UI: 28.69 - 61.44 ) |
| Male | Cardiovascular diseases | 301.89 (UI: 248.55 - 361.69 ) | 3.06 (UI: 2.48 - 3.75 ) | 42.15 (UI: 28.63 - 60.37 ) |
| Both | Chronic respiratory diseases | 257.81 (UI: 166.57 - 392.62 ) | 0.51 (UI: 0.37 - 0.7 ) | 214.5 (UI: 122.49 - 349.55 ) |
| Female | Chronic respiratory diseases | 222.47 (UI: 144.99 - 341.95 ) | 0.47 (UI: 0.32 - 0.76 ) | 181.74 (UI: 101.85 - 292.52 ) |
| Male | Chronic respiratory diseases | 291.24 (UI: 185.41 - 447.77 ) | 0.54 (UI: 0.38 - 0.76 ) | 245.49 (UI: 137.74 - 404.22 ) |
| Both | Diabetes and kidney diseases | 99.35 (UI: 82.95 - 119.36 ) | 1.01 (UI: 0.82 - 1.23 ) | 14.43 (UI: 9.16 - 21.24 ) |
| Female | Diabetes and kidney diseases | 101.37 (UI: 82.45 - 123.57 ) | 1.02 (UI: 0.81 - 1.29 ) | 15.11 (UI: 9.94 - 22.54 ) |
| Male | Diabetes and kidney diseases | 97.43 (UI: 76.48 - 124.72 ) | 0.99 (UI: 0.74 - 1.29 ) | 13.79 (UI: 8.48 - 20.71 ) |
| Both | Digestive diseases | 85.89 (UI: 68.94 - 107.79 ) | 0.51 (UI: 0.42 - 0.64 ) | 42.96 (UI: 29.17 - 61.18 ) |
| Female | Digestive diseases | 85.66 (UI: 67.44 - 108.16 ) | 0.48 (UI: 0.38 - 0.64 ) | 45.25 (UI: 29.94 - 63.98 ) |
| Male | Digestive diseases | 86.11 (UI: 67.39 - 109.62 ) | 0.54 (UI: 0.42 - 0.71 ) | 40.81 (UI: 27.64 - 57.91 ) |
| Both | Enteric infections | 196.43 (UI: 150.02 - 257.45 ) | 1.47 (UI: 1.03 - 2.05 ) | 68.17 (UI: 40.94 - 104.43 ) |
| Female | Enteric infections | 217.68 (UI: 159.96 - 295.07 ) | 1.62 (UI: 1.04 - 2.47 ) | 75.17 (UI: 43.61 - 117.49 ) |
| Male | Enteric infections | 176.32 (UI: 128.86 - 234.69 ) | 1.32 (UI: 0.89 - 1.9 ) | 61.55 (UI: 36.16 - 94.06 ) |
| Both | HIV/AIDS and sexually transmitted infections | 116.14 (UI: 45.41 - 238.49 ) | 1.29 (UI: 0.51 - 2.66 ) | 0.38 (UI: 0.21 - 0.65 ) |
| Female | HIV/AIDS and sexually transmitted infections | 112.23 (UI: 45.28 - 231.17 ) | 1.25 (UI: 0.51 - 2.58 ) | 0.26 (UI: 0.14 - 0.43 ) |
| Male | HIV/AIDS and sexually transmitted infections | 119.84 (UI: 45.18 - 249.78 ) | 1.33 (UI: 0.5 - 2.78 ) | 0.51 (UI: 0.24 - 0.94 ) |
| Both | Maternal and neonatal disorders | 2899.07 (UI: 2430.48 - 3442.56 ) | 28.54 (UI: 23.32 - 34.64 ) | 332.47 (UI: 240.18 - 435.89 ) |
| Female | Maternal and neonatal disorders | 2540.65 (UI: 2132.25 - 2987.71 ) | 24.67 (UI: 20.13 - 29.63 ) | 322.96 (UI: 230.04 - 423.8 ) |
| Male | Maternal and neonatal disorders | 3238.13 (UI: 2630.5 - 3930.31 ) | 32.21 (UI: 25.29 - 39.58 ) | 341.47 (UI: 241.94 - 452.75 ) |
| Both | Mental disorders | 1094.5 (UI: 749.57 - 1530.03 ) | 0 (UI: 0 - 0 ) | 1094.5 (UI: 749.57 - 1530.03 ) |
| Female | Mental disorders | 1102.96 (UI: 722.75 - 1577.47 ) | 0 (UI: 0 - 0 ) | 1102.96 (UI: 722.75 - 1577.47 ) |
| Male | Mental disorders | 1086.51 (UI: 762.96 - 1500.71 ) | 0 (UI: 0 - 0 ) | 1086.51 (UI: 762.96 - 1500.71 ) |
| Both | Musculoskeletal disorders | 202.52 (UI: 132.47 - 294.26 ) | 0.08 (UI: 0.07 - 0.11 ) | 195.69 (UI: 125.72 - 286.19 ) |
| Female | Musculoskeletal disorders | 272.81 (UI: 180 - 396.61 ) | 0.12 (UI: 0.08 - 0.16 ) | 263.52 (UI: 171.96 - 387.63 ) |
| Male | Musculoskeletal disorders | 136.02 (UI: 83.84 - 199.79 ) | 0.05 (UI: 0.03 - 0.07 ) | 131.53 (UI: 79.27 - 195.02 ) |
| Both | Neglected tropical diseases and malaria | 52.56 (UI: 32.39 - 79.14 ) | 0.03 (UI: 0.02 - 0.07 ) | 49.89 (UI: 30.32 - 76.73 ) |
| Female | Neglected tropical diseases and malaria | 62.01 (UI: 38.08 - 96.22 ) | 0.03 (UI: 0.02 - 0.06 ) | 59.22 (UI: 35.36 - 93.63 ) |
| Male | Neglected tropical diseases and malaria | 43.62 (UI: 25.68 - 68.44 ) | 0.03 (UI: 0.01 - 0.07 ) | 41.06 (UI: 23.4 - 66.32 ) |
| Both | Neoplasms | 304.91 (UI: 242.75 - 379.12 ) | 3.62 (UI: 2.89 - 4.51 ) | 6.39 (UI: 4.27 - 9.56 ) |
| Female | Neoplasms | 247.32 (UI: 198.38 - 312.77 ) | 2.92 (UI: 2.34 - 3.69 ) | 5.35 (UI: 3.48 - 8.33 ) |
| Male | Neoplasms | 359.38 (UI: 276.85 - 453.11 ) | 4.29 (UI: 3.3 - 5.42 ) | 7.38 (UI: 4.71 - 11.02 ) |
| Both | Neurological disorders | 471.63 (UI: 182.6 - 882.85 ) | 0.92 (UI: 0.74 - 1.12 ) | 394.3 (UI: 107.84 - 800.67 ) |
| Female | Neurological disorders | 489.39 (UI: 187.75 - 943.56 ) | 0.82 (UI: 0.64 - 1.05 ) | 420.14 (UI: 117 - 877.42 ) |
| Male | Neurological disorders | 454.84 (UI: 187.85 - 836.46 ) | 1.01 (UI: 0.79 - 1.28 ) | 369.86 (UI: 105.66 - 753.97 ) |
| Both | Nutritional deficiencies | 419.26 (UI: 258.46 - 636.4 ) | 0.14 (UI: 0.11 - 0.19 ) | 406.95 (UI: 246.08 - 623.71 ) |
| Female | Nutritional deficiencies | 500.44 (UI: 300.92 - 783.79 ) | 0.16 (UI: 0.12 - 0.21 ) | 486.56 (UI: 286.07 - 770.17 ) |
| Male | Nutritional deficiencies | 342.47 (UI: 200.13 - 544.61 ) | 0.13 (UI: 0.09 - 0.17 ) | 331.64 (UI: 188.6 - 535.74 ) |
| Both | Other infectious diseases | 155.31 (UI: 111.23 - 242.07 ) | 1.29 (UI: 0.86 - 2.23 ) | 44.02 (UI: 28.28 - 66.04 ) |
| Female | Other infectious diseases | 164.19 (UI: 114.88 - 262.36 ) | 1.32 (UI: 0.85 - 2.37 ) | 50.21 (UI: 31 - 77.16 ) |
| Male | Other infectious diseases | 146.91 (UI: 104.16 - 224.88 ) | 1.26 (UI: 0.83 - 2.11 ) | 38.17 (UI: 24.22 - 57.24 ) |
| Both | Other non-communicable diseases | 2685.36 (UI: 2208.3 - 3303.73 ) | 26.11 (UI: 21.01 - 33.13 ) | 374.63 (UI: 268.15 - 525.52 ) |
| Female | Other non-communicable diseases | 2610.19 (UI: 2170.85 - 3127.03 ) | 24.92 (UI: 20.33 - 30.64 ) | 405.15 (UI: 287.84 - 564.12 ) |
| Male | Other non-communicable diseases | 2756.48 (UI: 2170.09 - 3554.58 ) | 27.24 (UI: 20.86 - 36.08 ) | 345.77 (UI: 242.23 - 481.08 ) |
| Both | Respiratory infections and tuberculosis | 829.67 (UI: 669.93 - 1102.24 ) | 6.85 (UI: 5.71 - 8.3 ) | 235.36 (UI: 125.52 - 487.41 ) |
| Female | Respiratory infections and tuberculosis | 791.52 (UI: 621.2 - 1060.39 ) | 6.41 (UI: 5.18 - 7.85 ) | 233.86 (UI: 122.09 - 482.09 ) |
| Male | Respiratory infections and tuberculosis | 865.76 (UI: 680.07 - 1159.47 ) | 7.27 (UI: 6 - 8.97 ) | 236.78 (UI: 125.52 - 489.51 ) |
| Both | Self-harm and interpersonal violence | 90.79 (UI: 73.08 - 113.66 ) | 0.89 (UI: 0.69 - 1.16 ) | 17.59 (UI: 12.58 - 23.51 ) |
| Female | Self-harm and interpersonal violence | 76.95 (UI: 57.4 - 105.39 ) | 0.68 (UI: 0.45 - 0.99 ) | 20.93 (UI: 14.46 - 29.14 ) |
| Male | Self-harm and interpersonal violence | 103.87 (UI: 78.34 - 138.76 ) | 1.1 (UI: 0.79 - 1.51 ) | 14.44 (UI: 10.58 - 18.76 ) |
| Both | Sense organ diseases | 129.95 (UI: 85.36 - 189.77 ) | NA | 129.95 (UI: 85.36 - 189.77 ) |
| Female | Sense organ diseases | 130.32 (UI: 86.29 - 192.99 ) | NA | 130.32 (UI: 86.29 - 192.99 ) |
| Male | Sense organ diseases | 129.6 (UI: 85.53 - 191.03 ) | NA | 129.6 (UI: 85.53 - 191.03 ) |
| Both | Skin and subcutaneous diseases | 458.26 (UI: 292.69 - 673.36 ) | 0.03 (UI: 0.02 - 0.04 ) | 455.77 (UI: 289.8 - 670.92 ) |
| Female | Skin and subcutaneous diseases | 494.73 (UI: 318.44 - 731.56 ) | 0.04 (UI: 0.03 - 0.05 ) | 491.65 (UI: 315.22 - 728.23 ) |
| Male | Skin and subcutaneous diseases | 423.75 (UI: 271.85 - 621.28 ) | 0.02 (UI: 0.02 - 0.03 ) | 421.82 (UI: 269.63 - 619.02 ) |
| Both | Substance use disorders | 1.77 (UI: 0.86 - 3.11 ) | 0 (UI: 0 - 0 ) | 1.77 (UI: 0.86 - 3.11 ) |
| Female | Substance use disorders | 1.3 (UI: 0.54 - 2.51 ) | 0 (UI: 0 - 0 ) | 1.3 (UI: 0.54 - 2.51 ) |
| Male | Substance use disorders | 2.2 (UI: 1.01 - 3.93 ) | 0 (UI: 0 - 0 ) | 2.2 (UI: 1.01 - 3.93 ) |
| Both | Transport injuries | 459.4 (UI: 382.07 - 559.55 ) | 5.32 (UI: 4.4 - 6.51 ) | 19.06 (UI: 13.27 - 26.17 ) |
| Female | Transport injuries | 323.6 (UI: 261.19 - 395.53 ) | 3.62 (UI: 2.87 - 4.47 ) | 19.63 (UI: 13.85 - 27.03 ) |
| Male | Transport injuries | 587.85 (UI: 478.11 - 734.47 ) | 6.92 (UI: 5.61 - 8.68 ) | 18.52 (UI: 13.06 - 26.04 ) |
| Both | Unintentional injuries | 483.22 (UI: 410.45 - 577.44 ) | 4.91 (UI: 4.1 - 5.93 ) | 72.89 (UI: 49.66 - 102.61 ) |
| Female | Unintentional injuries | 381.11 (UI: 322.4 - 449.91 ) | 3.67 (UI: 3.01 - 4.41 ) | 70.45 (UI: 47.47 - 99.4 ) |
| Male | Unintentional injuries | 579.81 (UI: 477.46 - 708.57 ) | 6.08 (UI: 4.93 - 7.49 ) | 75.2 (UI: 52.34 - 106.05 ) |
ds1 %>%
filter(age =="0-14 years" , location=="Jordan", metric=="Number", measure =="DALYs (Disability-Adjusted Life Years)", sex=="Both" ) %>%
mutate(val=paste(round(val, 2), "(UI:", round(lower, 2), "-", round(upper, 2), ")")) %>%
select(-c(upper, lower, metric)) %>%
tidyr::spread(year, val) %>% select(-c(age, location, measure, sex)) %>% gt()
| cause | 1990 | 2000 | 2010 | 2020 | 2021 |
|---|---|---|---|---|---|
| Communicable, maternal, neonatal, and nutritional diseases | 273225.65 (UI: 239391.15 - 314247.53 ) | 236930.65 (UI: 207164.43 - 268125.2 ) | 222583.57 (UI: 191544.31 - 257171.45 ) | 174502.67 (UI: 148051.31 - 207770.73 ) | 169606.16 (UI: 145118.08 - 202268.7 ) |
| Injuries | 42387.23 (UI: 37778.5 - 46989.39 ) | 47684.99 (UI: 42725.72 - 52929.48 ) | 43568.71 (UI: 38943.16 - 48906.24 ) | 38594.03 (UI: 33290.19 - 45107.51 ) | 37543.82 (UI: 32226.41 - 44188.53 ) |
| Non-communicable diseases | 198523.77 (UI: 163797.46 - 229303.97 ) | 198173.06 (UI: 172772.97 - 226043.94 ) | 214343.7 (UI: 186007.21 - 248780.73 ) | 221033.15 (UI: 183077.94 - 268049.54 ) | 220325.89 (UI: 182813.85 - 265275.55 ) |
| Other COVID-19 pandemic-related outcomes | 0 (UI: 0 - 0 ) | 0 (UI: 0 - 0 ) | 0 (UI: 0 - 0 ) | 545.93 (UI: 0 - 3156.08 ) | 1676.8 (UI: 0 - 6107.9 ) |
children <- c("<5 years" ,"5-9 years","10-14 years")
measures <- c("Deaths", "DALYs (Disability-Adjusted Life Years)", "YLDs (Years Lived with Disability)")
create_plot <- function(data, Location, Measure, y_label) {
data %>%
mutate(age = factor(age, levels = children)) %>%
filter(age %in% children, location == Location, metric == "Number", measure == Measure, sex == "Both") %>%
select(-c(upper, lower, metric)) %>%
ggplot(aes(x = age, y = val, fill = cause)) +
geom_col(position = "fill") +
theme_classic() +
labs(y = y_label, x = "Age Group", fill = "Cause of DALYs") +
theme(
axis.title.x = element_text(size = 12),
axis.title.y = element_text(size = 12),
legend.title = element_text(size = 12),
legend.text = element_text(size = 10)
)+
guides(fill = guide_legend(nrow = 2, byrow = TRUE)) # Set legend to two rows
}
A <- create_plot(ds1, "Jordan", "DALYs (Disability-Adjusted Life Years)", "Proportion of Total DALYs by Cause")
B <- create_plot(ds1, "Global", "DALYs (Disability-Adjusted Life Years)", "Proportion of Total DALYs by Cause")
C <- create_plot(ds1, "Jordan", "Deaths", "Proportion of Total Deaths by Cause")
D <- create_plot(ds1, "Global", "Deaths", "Proportion of Total Deaths by Cause")
ggpubr::ggarrange(A,B,C,D, labels="AUTO", legend="top", common.legend = T)
library(ggplot2)
library(dplyr)
library(tidyr)
library(ggpubr)
children <- c("<5 years", "5-9 years", "10-14 years")
measures <- c("Deaths", "DALYs (Disability-Adjusted Life Years)", "YLDs (Years Lived with Disability)")
create_plot_by_sex <- function(data, Location, Measure, y_label) {
data %>%
filter(age %in% children, location == Location, metric == "Number", measure == Measure) %>%
select(-c(upper, lower, metric)) %>%
ggplot(aes(x = sex, y = val, fill = cause)) +
geom_col(position = "fill") +
theme_classic() +
labs(y = y_label, x = "Sex", fill = "Cause of DALYs") +
theme(
axis.title.x = element_text(size = 12),
axis.title.y = element_text(size = 12),
legend.title = element_text(size = 12),
legend.text = element_text(size = 10)
) +
guides(fill = guide_legend(nrow = 2, byrow = TRUE)) # Set legend to two rows
}
A_sex <- create_plot_by_sex(ds1, "Jordan", "DALYs (Disability-Adjusted Life Years)", "Proportion of Total DALYs by Cause")
B_sex <- create_plot_by_sex(ds1, "Global", "DALYs (Disability-Adjusted Life Years)", "Proportion of Total DALYs by Cause")
C_sex <- create_plot_by_sex(ds1, "Jordan", "Deaths", "Proportion of Total Deaths by Cause")
D_sex <- create_plot_by_sex(ds1, "Global", "Deaths", "Proportion of Total Deaths by Cause")
ggpubr::ggarrange(A_sex, B_sex, C_sex, D_sex, labels = "AUTO", legend = "top", common.legend = TRUE)
create_trend_plot <- function(data, Location, Measure, y_label) {
data %>%
filter(age == "0-14 years", location == Location, metric == "Rate", measure == Measure, sex == "Both") %>%
select(-c(upper, lower, metric)) %>%
ggplot(aes(x = year, y = val, color = cause, group = cause)) +
geom_point() +
geom_smooth(se = FALSE) +
theme_classic() +
labs(y = y_label, x = "Year", color = "Cause") +
guides(color = guide_legend(nrow = 2, byrow = TRUE))
}
# Create the trend plots
trend_DALYs <- create_trend_plot(ds1, "Jordan", "DALYs (Disability-Adjusted Life Years)", "Annual DALYs Rate (per 100,000)")
trend_Deaths <- create_trend_plot(ds1, "Jordan", "Deaths", "Annual Deaths Rate (per 100,000)")
# Combine the trend plots into a single figure
ggpubr::ggarrange(trend_DALYs, trend_Deaths, labels = "AUTO", ncol = 2, nrow = 1, common.legend=T)
## Treemaps showing the distribution of disability-adjusted life years
(DALYs) among children aged 0-14 years in Jordan (A) and globally (B) in
2021. The size of each rectangle represents the proportion of total
DALYs attributed to each cause.
library(treemap)
# Function to create a treemap
create_treemap <- function(data, Location) {
filtered_data <- data %>%
filter(age == "0-14 years", location == Location, metric == "Number", measure == "DALYs (Disability-Adjusted Life Years)", sex == "Both") %>%
group_by(cause) %>%
summarise(val = sum(val, na.rm = TRUE))
treemap_data <- filtered_data %>%
select(cause, val)
treemap(treemap_data,
index = "cause",
vSize = "val",
title = paste("Causes of DALYs in", Location),
palette = "Set3",
fontsize.labels = 10)
}
# Create the treemap plots
png("treemap_jordan.png")
create_treemap(ds2, "Jordan")
dev.off()
## png
## 2
png("treemap_world.png")
create_treemap(ds2, "Global")
dev.off()
## png
## 2
# Combine the treemap images into a single figure
library(grid)
library(gridExtra)
##
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
##
## combine
treemap_jordan <- rasterGrob(png::readPNG("treemap_jordan.png"), interpolate = TRUE)
treemap_world <- rasterGrob(png::readPNG("treemap_world.png"), interpolate = TRUE)
grid.arrange(treemap_jordan, treemap_world, ncol = 2)