Description Usage Arguments Value Examples
icd9Count
takes a data frame with a column for
visitId
and another for ICD-9 code, and returns the number of
distinct codes for each patient.
The visitId field is typically the first column. If there is no column
called visitId
and visitId
is not specified, the first column
is used.
icd9CountComorbidBin
differs from the other counting
functions in that it counts _comorbidities_, not individual diagnoses. It
accepts any data frame with either logicals or zero/non-zero contents, with
a single column for visitId. No checks are made to see whether visitId is
duplicated.
For icd9Count
, it is assumed that all the columns apart
from visitId
represent actual or possible ICD-9 codes. Duplicate
visitId
s are repeated as given and aggregated.
1 2 3 4 5 |
x |
data frame with one row per patient, and a true/false or 1/0 flag
for each column. By default, the first column is the patient identifier and
is not counted. If |
visitId |
The name of the column in the data frame which contains the
patient or visit identifier. Typically this is the visit identifier, since
patients come leave and enter hospital with different ICD-9 codes. It is a
character vector of length one. If left empty, or |
return.df |
single logical, if |
aggregate, |
single logical, default is FALSE. If TRUE, the length (or rows) of the output will no longer match the input, but duplicate visitIds will be counted together. |
vector of the count of comorbidities for each patient. This is sometimes used as a metric of comorbidity load, instead of, or inaddition to metrics like the Charlson Comorbidity Index (aka Charlson Score)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | mydf <- data.frame(visitId = c("r", "r", "s"),
icd9 = c("441", "412.93", "044.9"))
icd9Count(mydf, return.df = TRUE)
icd9Count(mydf)
cmb <- icd9ComorbidQuanDeyo(mydf, isShort = FALSE, return.df = TRUE)
icd9CountComorbidBin(cmb)
wide <- data.frame(visitId = c("r", "s", "t"),
icd9_1 = c("0011", "441", "456"),
icd9_2 = c(NA, "442", NA),
icd9_3 = c(NA, NA, "510"))
icd9CountWide(wide)
# or:
library(magrittr)
wide %>% icd9WideToLong %>% icd9Count
|
The icd9 package is now deprecated. The new 'icd' package is on CRAN and has ICD-10 support and bug-fixes. All the functions available in 'icd9' have been preserved in 'icd', but a simpler set of function names is also available.
To install it, use:
install.packages("icd")
# or for the development version:
devtools::install_github("jackwasey/icd")
Then:
remove.packages("icd9")
visitId icd9Count
1 r 2
2 s 1
[1] 2 1
r s
2 1
r s t
1 2 2
[1] 1 2 2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.