In [4]:
DT <- read.table("../Data/All_data.txt")
In [5]:
head(DT)
In [6]:
#Format
form <- function(x,type="Prop"){
paste(format(round(x[2],1),nsmall = 1),
ifelse(type=="Prop","% ["," ["),format(round(x[1],1),nsmall = 1),
"-",format(round(x[3],1),nsmall = 1),"]",sep="")
}
In [7]:
#For a given region, disease and metric of burden and research, we give all data in a readable format
readable_numbers <- function(r,d,metr_burden="daly",metr_res="RCTs"){
x <- DT[DT$Region==r & DT$Disease==d,c("Region","Disease",names(DT)[c(grep(metr_burden,names(DT)),grep(metr_res,names(DT)))])]
print(paste("In ",ifelse(r=="All","all regions",r), ", ",
ifelse(d=="All","all diseases",d), " caused ",
round(x[grep("^burden",names(x))]/1e6,1), " million ", metr_burden, "s", sep=""))
print(paste("In ",ifelse(r=="All","all regions",r), ", ",
ifelse(d=="All","all diseases",d),
ifelse(metr_res=="RCTs"," was studied by "," were enrolled "),
form(x[grep("Nb_",names(x))],"Nb"), " ", metr_res,sep=""))
print(paste("In ",ifelse(r=="All","all regions",r), ", ",
ifelse(d=="All","all diseases",d),
ifelse(metr_res=="RCTs"," was studied by "," were enrolled "),
form(x[grep("Nb_",names(x))]/rep((x[grep("^burden",names(x))]/1e6),3),"Nb"),
" per million ", metr_burden, "s", sep=""))
if(d!="All"){
print(paste("In ",ifelse(r=="All","all regions",r),
": the local proportion of burden (in ",metr_burden,") vs research (in ",
metr_res,") of ",d," was ",
round(x[intersect(grep(metr_burden,names(x)),grep("Prop_loc",names(x)))],1),
"% vs ",
form(x[intersect(grep(metr_res,names(x)),grep("Prop_loc",names(x)))]),sep=""
))
}
if(r!="All"){
print(paste("For ",ifelse(d=="All","all diseases",d),
": the global proportion of burden (in ",metr_burden,") vs research (in ",
metr_res,") in ",r," was ",
round(x[intersect(grep(metr_burden,names(x)),grep("Prop_glob",names(x)))],1),
"% vs ",
form(x[intersect(grep(metr_res,names(x)),grep("Prop_glob",names(x)))]),sep=""
))
}
if(!r%in%c("All","High-income","Non-HI")){
print(paste("For ",ifelse(d=="All","all diseases",d),
": the proportion among non-high-income regions of burden (in ",metr_burden,
") vs research (in ",metr_res,") in ",r," was ",
round(x[intersect(grep(metr_burden,names(x)),grep("Prop_NHI",names(x)))],1),
"% vs ",
form(x[intersect(grep(metr_res,names(x)),grep("Prop_NHI",names(x)))]),sep=""
))
}
}
In [8]:
levels(DT$Region)
levels(DT$Disease)
In [9]:
readable_numbers(r = "High-income", d = "Cardiovascular and circulatory diseases", metr_burden = "daly", metr_res = "RCTs")
In [10]:
readable_numbers(r = "All", d = "All", metr_burden = "daly", metr_res = "RCTs")
In [11]:
levels(DT$Disease)
In [12]:
readable_numbers(r = "All",
d = "Diarrhea, lower respiratory infections, meningitis, and other common infectious diseases",
metr_burden = "daly",
metr_res = "RCTs")
In [13]:
readable_numbers(r = "All",
d = "Neonatal disorders",
metr_burden = "daly",
metr_res = "RCTs")
In [14]:
readable_numbers(r = "Non-HI",
d = "All",
metr_burden = "daly",
metr_res = "Patients")
In [15]:
readable_numbers(r = "High-income",
d = "All",
metr_burden = "daly",
metr_res = "Patients")
In [16]:
readable_numbers(r = "All",
d = "Mental and behavioral disorders",
metr_burden = "daly",
metr_res = "RCTs")
In [17]:
gaps <- function(r,metr_burden="daly",metr_res="RCTs"){
print("-------------------------------------------")
print(paste("Gaps comparing local proportion of burden in ",metr_burden,
"s vs local proportion of research in ",metr_res,sep=""))
x <- DT[DT$Region==r,c("Region","Disease",names(DT)[c(grep(metr_burden,names(DT)),grep(metr_res,names(DT)))])]
x <- x[!is.na(x[,intersect(intersect(grep(metr_res,names(x)),grep("Prop_loc",names(x))),grep("up",names(x)))])
& x[,intersect(grep(metr_burden,names(x)),grep("Prop_loc",names(x)))] >
2*x[,intersect(intersect(grep(metr_res,names(x)),grep("Prop_loc",names(x))),grep("up",names(x)))],]
x <- x[order(x[,intersect(grep(metr_burden,names(x)),grep("Prop_loc",names(x)))],decreasing=TRUE),]
print(paste(r,": ",nrow(x)," gaps found:",sep=""))
if(nrow(x)!=0){
for(i in 1:nrow(x)){
k <- x[i,]
print(paste(k$Disease,": ",form(k[intersect(grep(metr_res,names(x)),grep("Prop_loc",names(x)))]), " vs ",
round(k[intersect(grep(metr_burden,names(x)),grep("Prop_loc",names(x)))],1),"%",sep=""))
}
}
}
In [18]:
r <- 'Sub-Saharian Africa'
metr_burden <- "daly"
metr_res <- "RCTs"
In [19]:
gaps(r,metr_burden,metr_res)
In [20]:
regs <- levels(DT$Region)
regs <- regs[regs!="Non-HI"]
lapply(regs,gaps)
In [21]:
readable_numbers(r = "Sub-Saharian Africa",
d = "HIV/AIDS")
In [22]:
readable_numbers(r = "Sub-Saharian Africa",
d = "Malaria")
In [23]:
regs
In [24]:
lapply(regs,function(x){gaps(r=x,metr_res="Patients")})
In [25]:
r <- 'Sub-Saharian Africa'
metr_burden <- "daly"
metr_res <- "Patients"
In [26]:
gaps(r = r,metr_burden = metr_burden, metr_res=metr_res)
In [27]:
x <- DT[DT$Region==r,c("Region","Disease",names(DT)[c(grep(metr_burden,names(DT)),grep(metr_res,names(DT)))])]
In [28]:
x <- x[!is.na(x[,intersect(intersect(grep(metr_res,names(x)),grep("Prop_loc",names(x))),grep("up",names(x)))])
& x[,intersect(grep(metr_burden,names(x)),grep("Prop_loc",names(x)))] >
2*x[,intersect(intersect(grep(metr_res,names(x)),grep("Prop_loc",names(x))),grep("up",names(x)))],]
In [29]:
x <- x[order(x[,intersect(grep(metr_burden,names(x)),grep("Prop_loc",names(x)))],decreasing=TRUE),]
In [30]:
x
In [31]:
readable_numbers(r = "Southeast Asia, East Asia and Oceania",
d = "Cardiovascular and circulatory diseases",
metr_burden="daly",
metr_res="Patients")
In [32]:
readable_numbers(r = "Sub-Saharian Africa",
d = "Diarrhea, lower respiratory infections, meningitis, and other common infectious diseases",
metr_burden="daly",
metr_res="RCTs")
In [34]:
readable_numbers(r = "All",
d = "All",
metr_burden="yll",
metr_res="RCTs")
In [35]:
readable_numbers(r = "All",
d = "All",
metr_burden="yld",
metr_res="RCTs")
In [36]:
readable_numbers(r = "All",
d = "All",
metr_burden="death",
metr_res="RCTs")
In [ ]: