count_comorbid: Count number of comorbidities per patient

Description Usage Arguments

View source: R/score.R

Description

count_comorbid differs from the other counting functions in that it counts comorbidities, not individual diagnoses. It accepts any data.frame with either logical or binary contents, with a single column for visit_name. No checks are made to see whether visit_name is duplicated.

Usage

1
count_comorbid(x, visit_name = get_visit_name(x), return_df = FALSE)

Arguments

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 is not specified, the first column is used.

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 NULL, then an attempt is made to guess which field has the ID for the patient encounter (not a patient ID, although this can of course be specified directly). The guesses proceed until a single match is made. Data frames may be wide with many matching fields, so to avoid false positives, anything but a single match is rejected. If there are no successful guesses, and visit_id was not specified, then the first column of the data frame is used.

return_df

single logical value, if TRUE, return 'tidy' data, i.e., the result is a data frame with the first column being the visit_id, and the second being the count. If visit_id was a factor or named differently in the input, this is preserved.


jackwasey/icd documentation built on Nov. 23, 2021, 9:56 a.m.