Skip to contents

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 with R book.

Load Sample Data

hmsidwR::sdi90_19 |>
  head()
#>   location year value
#> 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()
#>   location    sex   age                               cause        dx     upper
#> 1   France   male 10-14 Tracheal, bronchus, and lung cancer 0.3214538 0.4524740
#> 2   France female 10-14 Tracheal, bronchus, and lung cancer 0.4186573 0.7101662
#> 3   France   both 10-14 Tracheal, bronchus, and lung cancer 0.7401111 1.1441821
#> 4   France   male 15-19 Tracheal, bronchus, and lung cancer 1.0288445 1.4128852
#> 5   France female 15-19 Tracheal, bronchus, and lung cancer 1.1029335 1.8145559
#> 6   France   both 15-19 Tracheal, bronchus, and lung cancer 2.1317780 2.9363421
#>       lower
#> 1 0.2243492
#> 2 0.2275731
#> 3 0.4601763
#> 4 0.7247192
#> 5 0.6343383
#> 6 1.5632524

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)