Skip to content

Instantly share code, notes, and snippets.

@seabbs
Last active January 9, 2018 14:20
Show Gist options
  • Save seabbs/984275578733de0a2724748ea856b5ec to your computer and use it in GitHub Desktop.
Save seabbs/984275578733de0a2724748ea856b5ec to your computer and use it in GitHub Desktop.
Explore 20 countries with highest TB incidence
# install.packages("getTBinR")
library(getTBinR)
# install.packages("tidyverse")
library(tidyverse)
# Get the data
tb_burden <- get_tb_burden(download_data = TRUE, save = TRUE)
dict <- get_data_dict(download_data = TRUE, save = TRUE)
# Look up variables with mortality in their definition
search_data_dict(def = "incidence")
# Map incidence rates in 2016
map_tb_burden(metric = "e_inc_100k", year = 2016)
# Get countries with highest incidence rates in the data
high_inc_countries <- tb_burden %>%
filter(year == 2016) %>%
group_by(country) %>%
summarise(e_inc_100k = max(e_inc_100k)) %>%
ungroup %>%
arrange(desc(e_inc_100k)) %>%
slice(1:20) %>%
pull(country) %>%
unique
#Overview of 20 countries with incidence rates
plot_tb_burden_overview(metric = "e_inc_100k",
countries = high_inc_countries)
# Trends over time in incidence rates by country for countries with highest incidence rates
plot_tb_burden(countries = high_inc_countries,
facet = "country", scales = "free_y")
# Trends over time in mortality rates (exc HIV) by country
plot_tb_burden(metric = "e_mort_exc_tbhiv_100k",
countries = high_inc_countries,
facet = "country", scales = "free_y")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment