Jordan A. Kempker, MD, MSc
2017-02-17
This presentation examines the annual trends of drug resistant tuberculosis by WHO Region.
The analysis uses the following packages.
require(ggplot2)
require(dplyr)
require(tidyr)
require(devtools)
require(plotly)
Data is pulled from World Health Organization at the following website:
http://apps.who.int/gho/data/node.main.1315?lang=en
url<-
"http://apps.who.int/gho/athena/data/GHO/TB_e_rr_in_notified_pulm,TB_c_dst_rlt_new_pct,TB_c_dst_rlt_ret_pct,TB_rr_mdr,TB_c_mdr_tx?filter=COUNTRY:-;REGION:*&x-sideaxis=REGION;YEAR&x-topaxis=GHO&profile=crosstable&format=csv"
download.file(url, destfile="./DR_TB.csv")
dr_tb<-read.csv("./DR_TB.csv", stringsAsFactors = F )
Variables are renamed and data is changed to numeric and data frame to long format.
colnames(dr_tb)<- c("Region","Year","drop", "New.Percent.Tested", "Treated.Percent.Tested", "Confirmed.Cases", "Suspected.Cases")
dr_tb <- dr_tb %>%
dplyr::select(-drop)%>%
mutate(Region=as.factor(Region),
Confirmed.Cases = as.numeric(gsub(" ", "", Confirmed.Cases, fixed = TRUE)),
Suspected.Cases = as.numeric(gsub(" ", "", Suspected.Cases, fixed = TRUE)),
New.Percent.Tested = as.numeric(New.Percent.Tested),
Treated.Percent.Tested= as.numeric(Treated.Percent.Tested))
dr_tb_long<-gather(dr_tb, Case.Type, Value, New.Percent.Tested:Suspected.Cases, factor_key = T)
g0<- ggplot(dr_tb_long[dr_tb_long$Case.Type==c("New.Percent.Tested","Treated.Percent.Tested"),], aes(Year, Value, color=Region))+
facet_grid(.~Case.Type)+
geom_path()+
ylab("Cases tested for RR/MDR TB,%")+
theme_bw()
ggplotly(g0)
g1<-ggplot(dr_tb_long[dr_tb_long$Case.Type==c("Confirmed.Cases","Suspected.Cases"),], aes(Year, Value, color=Region))+
facet_grid(.~Case.Type)+
geom_path()+
ylab("Number of Cases")+
theme_bw()
ggplotly(g1)