knitr::opts_chunk$set(echo = TRUE) library("icd") n <- 10000 set.seed(1441) dat <- data.frame(id = n + seq(n), icd_dx1 = sample(icd10cm2016$code, n, replace = TRUE), icd_dx2 = sample(icd10cm2016$code, n, replace = TRUE), icd_pcs1 = sample(icd10_pcs_2018$pcs, n, replace = TRUE), icd_pcs2 = sample(icd10_pcs_2018$pcs, n, replace = TRUE) )
The adult comorbidities defined by authors such as Charlson, Quan and Elixhuaser are not suitable for pediatric research. Feudtner and others produced comorbidity definitions suitable for infants and children, with mappings defined for both ICD-9 and ICD-10 codes. These are now included in the icd package for R, which enables fast calculation of comorbidities for PCCC and other ICD code to comorbidity maps.
The PCCC comorbidities may be derived from both diagnostic and procedure codes. The following simulated data has both:
The data is in 'wide' format. Currently
icd requires it be in 'long' format, which can be achieved as follows:
dx <- wide_to_long(dat[1:3]) pcs <- wide_to_long(dat[c(1, 4:5)], icd_name = "pcs", icd_regex = "icd_pcs") head(dx) head(pcs)
Now the PCCC comorbidity classes can be computed and summarized in a plot:
pccc_dx <- comorbid_pccc_dx(dx) pccc_pcs <- icd10_comorbid_pccc_pcs(pcs, visit_name = "id", icd_name = "pcs") res <- pccc_dx | pccc_pcs
barplot(sort(colSums(res), decreasing = TRUE), ylim = c(0, 70), ylab = "count", las = 2)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.