setwd("~/Desktop/cdsc/health literacy/") mapping = read.delim("Mapping - Sheet1.tsv") mapping <- mapping[,colnames(mapping) != "Notes"] IHME = read.csv("IHME_Data.csv") best <- read.csv("Best_Data.csv") # first, create the list of all the one-to-ones d <- merge(best, mapping[!is.na(mapping$Mapping_Type) & mapping$Mapping_Type == "one-to-one",], by.x="Reconciled_Name", by.y="Best_Disease_Name", all=TRUE) # now merge the imhe data on d <- merge(d, IHME[IHME$measure_name == "DALYs (Disability-Adjusted Life Years)", c("cause_id", "measure_name", "year", "val")], by.x=c("IHME_Cause_ID", "Year"), by.y=c("cause_id", "year")) # next, handle the one-to-manys but summing up