I want to change the ICD-10 code in a row to the name of the disease, according to the ICD-10 code dictionary provided.
This is initial data
id <- c("1","2","3")
Dx1 <- c("E119", "I251","I20")
Dx2 <- c("I20", "I251","E119")
Dx3 <- c("I251", "E119","I20")
df <- data.frame(id,Dx1,Dx2,Dx3)
df
This is the ICD-10 code dictionary, in this example there are 3 codes, but in reality, the ICD-10 code contains 94 thousand codes.
ICD <- c("I251", "E119","I20")
Disease <- c("Acute Myocard Infarct", "Type 2 Diabetes", "Chest Pain")
CodeDictionary <- data.frame(ICD,Disease)
CodeDictionary
and this is my target
id <- c("1","2","3")
Dx1 <- c("Type 2 Diabetes", "Acute Myocard Infarct","Chest Pain")
Dx2 <- c("Chest Pain", "Acute Myocard Infarct","Type 2 Diabetes")
Dx3 <- c("Acute Myocard Infarct", "Type 2 Diabetes","I20")
dfGoal <- data.frame(id,Dx1,Dx2,Dx3)
dfGoal
I tried the inner join from dplyr but it didn't work. Thank you for your help!