My dataframe has a set of columns that starts with "i10_dx". I would like to use the conversion key I have to create a new set of columns starting with "ccs" that corresponds to the former set of columns.
This is a snippet of dataframe
df <- data.frame(visitlink = c(1001976, 1001976, 1002247),
i10_dx1 = c("C7931", "C7949", NA),
i10_dx2 = c("G9519", "C7951", "C3490"),
i10_dx3 = c("G936", "C7931", "C7931"),
i10_dx4 = c("C7949", NA, "I10"))
This is the conversion key
key <- data.frame(icd10 = c("I10", "C3490", "C7931", "C7949", "C7951", "G936", "G9519"),
ccs = c("CIR007", "NEO022", "NEO070", "NEO070", "NEO070", "NVS020", "NVS020"))