# make ICD-9 toy data
df <- data.frame(
uid = 1:10, clnt_id = sample(1:3, 10, replace = TRUE),
diagx_1 = c("193", "2780", "396", "4254", "4150", "401", "401", "0932", "5329", "2536"),
diagx_2 = c(NA, NA, "72930", "V6542", "493", "405", "5880", "2409", "714", NA)
)
# compute Elixhauser Comorbidity Index by row
# uid is needed for by row calculation
# 3 categories were excluded in total_eci
compute_comorbidity(df,
vars = starts_with("diagx"),
icd_ver = "ICD-9-CM-5digits",
clnt_id = clnt_id, uid = uid,
excl = c("drug", "psycho", "dep")
)
# compute ECI by person
compute_comorbidity(df,
vars = starts_with("diagx"),
icd_ver = "ICD-9-CM-5digits",
clnt_id = clnt_id,
sum_by = "clnt"
)
Run the code above in your browser using DataLab