Description Usage Arguments Details Value Examples
count_codes
takes a data frame with a column for visit_name
and another for ICD-9 code, and returns the number of distinct codes for each
patient.
1 | count_codes(x, visit_name = get_visit_name(x), return_df = FALSE)
|
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 |
visit_name |
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 |
The visit_name
field is typically the first column. If there is no
column called visit_name
and visit_name
is not specified, the
first column is used.
vector of the count of comorbidities for each patient. This is sometimes used as a metric of comorbidity load, instead of, or in addition 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 17 18 19 20 21 22 23 24 25 | mydf <- data.frame(
visit_name = c("r", "r", "s"),
icd9 = c("441", "412.93", "042")
)
count_codes(mydf, return_df = TRUE)
count_codes(mydf)
cmb <- icd9_comorbid_quan_deyo(mydf, short_code = FALSE, return_df = TRUE)
count_comorbid(cmb)
wide <- data.frame(
visit_name = c("r", "s", "t"),
icd9_1 = c("0011", "441", "456"),
icd9_2 = c(NA, "442", NA),
icd9_3 = c(NA, NA, "510")
)
count_codes_wide(wide)
# or:
## Not run:
library(magrittr, warn.conflicts = FALSE)
wide %>%
wide_to_long() %>%
count_codes()
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.