comorbidity {comorbidity} | R Documentation |
Maps comorbidity conditions using algorithms from the Charlson and the Elixhauser comorbidity scores.
comorbidity(x, id, code, map, assign0, labelled = TRUE, tidy.codes = TRUE)
x |
A tidy |
id |
Column of |
code |
Column of |
map |
The mapping algorithm to be used (values are case-insensitive).
Possible values are the Charlson score with either ICD-10 or ICD-9-CM codes ( |
assign0 |
Apply a hierarchy of comorbidities: should a comorbidity be present in a patient with different degrees of severity, then the milder form will be assigned a value of 0. By doing this, a type of comorbidity is not counted more than once in each patient. The comorbidities that are affected by this argument are:
|
labelled |
Attach labels to each comorbidity, compatible with the RStudio viewer via the |
tidy.codes |
Tidy diagnostic codes?
If |
The ICD-10 and ICD-9-CM coding for the Charlson and Elixhauser scores is based on work by Quan et al. (2005).
ICD-10 and ICD-9 codes must be in upper case and with alphanumeric characters only in order to be properly recognised; set tidy.codes = TRUE
to properly tidy the codes automatically.
A message is printed to the R console when non-alphanumeric characters are found.
A data frame with id
, columns relative to each comorbidity domain, comorbidity score, weighted comorbidity score, and categorisations of such scores, with one row per individual.
For the Charlson score, the following variables are included in the dataset:
The id
variable as defined by the user;
mi
, for myocardial infarction;
chf
, for congestive heart failure;
pvd
, for peripheral vascular disease;
cevd
, for cerebrovascular disease;
dementia
, for dementia;
cpd
, for chronic pulmonary disease;
rheumd
, for rheumatoid disease;
pud
, for peptic ulcer disease;
mld
, for mild liver disease;
diab
, for diabetes without complications;
diabwc
, for diabetes with complications;
hp
, for hemiplegia or paraplegia;
rend
, for renal disease;
canc
, for cancer (any malignancy);
msld
, for moderate or severe liver disease;
metacanc
, for metastatic solid tumour;
aids
, for AIDS/HIV.
Please note that we combine "chronic obstructive pulmonary disease" and "chronic other pulmonary disease" for the Swedish version of the Charlson index, for comparability (and compatibility) with other definitions/implementations.
Conversely, for the Elixhauser score the dataset contains the following variables:
The id
variable as defined by the user;
chf
, for congestive heart failure;
carit
, for cardiac arrhythmias;
valv
, for valvular disease;
pcd
, for pulmonary circulation disorders;
pvd
, for peripheral vascular disorders;
hypunc
, for hypertension, uncomplicated;
hypc
, for hypertension, complicated;
para
, for paralysis;
ond
, for other neurological disorders;
cpd
, for chronic pulmonary disease;
diabunc
, for diabetes, uncomplicated;
diabc
, for diabetes, complicated;
hypothy
, for hypothyroidism;
rf
, for renal failure;
ld
, for liver disease;
pud
, for peptic ulcer disease, excluding bleeding;
aids
, for AIDS/HIV;
lymph
, for lymphoma;
metacanc
, for metastatic cancer;
solidtum
, for solid tumour, without metastasis;
rheumd
, for rheumatoid arthritis/collaged vascular disease;
coag
, for coagulopathy;
obes
, for obesity;
wloss
, for weight loss;
fed
, for fluid and electrolyte disorders;
blane
, for blood loss anaemia;
dane
, for deficiency anaemia;
alcohol
, for alcohol abuse;
drug
, for drug abuse;
psycho
, for psychoses;
depre
, for depression;
Labels are presented to the user when using the RStudio viewer (e.g. via the utils::View()
function) for convenience.
Quan H, Sundararajan V, Halfon P, Fong A, Burnand B, Luthi JC, et al. Coding algorithms for defining comorbidities in ICD-9-CM and ICD-10 administrative data. Medical Care 2005; 43(11):1130-1139.
Charlson ME, Pompei P, Ales KL, et al. A new method of classifying prognostic comorbidity in longitudinal studies: development and validation. Journal of Chronic Diseases 1987; 40:373-383.
Ludvigsson JF, Appelros P, Askling J et al. Adaptation of the Charlson Comorbidity Index for register-based research in Sweden. Clinical Epidemiology 2021; 13:21-41.
Sundararajan V, Henderson T, Perry C, Muggivan A, Quan H, Ghali WA. New ICD-10 version of the Charlson comorbidity index predicted in-hospital mortality. Journal of Clinical Epidemiology 2004; 57(12):1288-1294.
set.seed(1)
x <- data.frame(
id = sample(1:15, size = 200, replace = TRUE),
code = sample_diag(200),
stringsAsFactors = FALSE
)
# Charlson score based on ICD-10 diagnostic codes:
comorbidity(x = x, id = "id", code = "code", map = "charlson_icd10_quan", assign0 = FALSE)
# Elixhauser score based on ICD-10 diagnostic codes:
comorbidity(x = x, id = "id", code = "code", map = "elixhauser_icd10_quan", assign0 = FALSE)