Learn R Programming

icd (version 3.3)

count_codes_wide: Count ICD codes given in wide format

Description

For count_codes, it is assumed that all the columns apart from visit_name represent actual or possible ICD-9 codes. Duplicate visit_names are repeated as given and aggregated.

Usage

count_codes_wide(x, visit_name = get_visit_name(x), return_df = FALSE,
  aggr = FALSE)

icd_count_codes_wide(...)

Arguments

x

data.frame with one row per patient, hospital visit, encounter, etc., and multiple columns containing any ICD codes attributed to that encounter or patient. i.e. data frame with ICD codes in wide format.

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 the result as 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.

aggr

single logical, default is FALSE. If TRUE, the length (or rows) of the output will no longer match the input, but duplicate visit_names will be counted together.

...

arguments passed on to other functions

Deprecated function names

Future versions of icd will drop the icd_ prefix. For example, charlson should be used in favor of icd_charlson. To distinguish icd function calls, consider using the prefix icd:: instead, e.g., icd::charlson. Functions which specifically operate on either ICD-9 or ICD-10 codes or their sub-types will retain the prefix. E.g. icd9_comorbid_ahrq. icd specific classes also retain the prefix, e.g., icd_wide_data.