Setup
# install.packages("devtools")
devtools::install_github("Fgazzelloni/hmsidwR")
This package provides the set of data used in the Health Metrics and the Spread of Infectious Diseases Machine Learning Applications and Spatial Modeling Analysis book.
Load Sample Data
hmsidwR::sdi90_19 |>
head()
#> # A tibble: 6 × 3
#> location year value
#> <chr> <dbl> <dbl>
#> 1 Global 1990 0.511
#> 2 Global 1991 0.516
#> 3 Global 1992 0.521
#> 4 Global 1993 0.525
#> 5 Global 1994 0.529
#> 6 Global 1995 0.534
hmsidwR::deaths2019 |>
head()
#> # A tibble: 6 × 7
#> location sex age cause dx upper lower
#> <chr> <chr> <ord> <chr> <dbl> <dbl> <dbl>
#> 1 UK male <1 Lower respiratory infections 39.7 51.0 29.5
#> 2 UK female <1 Lower respiratory infections 30.0 38.0 22.6
#> 3 UK both <1 Lower respiratory infections 69.7 88.3 53.3
#> 4 UK male <1 Stroke 1.33 2.41 0.850
#> 5 UK female <1 Stroke 1.04 1.84 0.669
#> 6 UK both <1 Stroke 2.38 4.21 1.55
Make a Plot
library(tidyverse)
id <- hmsidwR::id_affected_countries %>%
ggplot(aes(
x = year,
group = location_name
)) +
geom_line(aes(y = YLLs),
linewidth = 0.2,
color = "grey"
) +
geom_line(
data = id_affected_countries %>%
filter(location_name %in% c(
"Lesotho",
"Eswatini",
"Malawi",
"Central African Republic",
"Zambia"
)),
aes(y = YLLs, color = location_name)
) +
theme_minimal() +
theme(legend.position = "none") +
labs(
title = "Countries with highest AVG YLLs",
subtitle = "due to infectious diseases from 1990 to 2021",
caption = "DataSource: IHME GBD Results for infectious diseases deaths and YLLs 1980 to 1999",
x = "Year", y = "DALYs"
)
# add a plotly version
library(plotly)
plotly::ggplotly(id)