Learn R Programming

icd (version 3.3)

condense: Condense ICD-9 code by replacing complete families with parent codes

Description

These functions take a set of ICD codes, and look for parent ICD codes in the hierarchy. If all the children of a parent are found, then the returned vector will just contain the parents of those codes. Any additional codes which did not have all the siblings present are retained. This can be thought of as the inverse operation to children.

Usage

condense(x, short_code = guess_short(x), defined = NULL, warn = TRUE,
  ...)

# S3 method for character condense(x, short_code = guess_short(x), defined = NULL, ...)

icd9_condense_decimal(x, defined = NULL, warn = TRUE, keep_factor_levels = FALSE)

icd9_condense_short(x, defined = NULL, warn = TRUE, keep_factor_levels = FALSE)

icd_condense.character(...)

icd_condense.icd9(...)

icd_condense(...)

Arguments

short_code

single logical value which determines whether the ICD-9 code provided is in short (TRUE) or decimal (FALSE) form. Where reasonable, this is guessed from the input data.

warn

single logical value, if TRUE, give warnings when there is discrepancy between onlyReal being TRUE yet data containing undefined codes.

...

arguments passed on to other functions

keep_factor_levels

single logical value, default FALSE. If TRUE, will reuse the factor levels from the input data for the output data. This only applies if a factor is given for the input codes.

icd9

is a character vector or factor of ICD-9 codes. If fewer than five characters is given in a code, then the digits are greedily assigned to hundreds, then tens, then units, before the decimal parts. E.g. "10" becomes "010", not "0010".

icd9Short

is a character vector of ICD-9 codes. If fewer than five characters is given in a code, then the digits are greedily assigned to hundreds, then tens, then units, before the decimal parts. E.g. "10" becomes "010", not "0010"

icd9Decimal

character vector of ICD-9 codes. If fewer than five characters is given in a code, then the digits are greedily assigned to hundreds, then tens, then units, before the decimal parts. E.g. "10" becomes "010", not "0010"

...

arguments passed on to other functions

Methods (by class)

  • character: Condense a set of ICD codes, guessing ICD version from input data

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.

See Also

Other ICD-9 ranges: children, expand_minor, expand_range

Examples

Run this code
# NOT RUN {
kids <- children("V40")
kids
condense(kids, defined = TRUE)
kids_with_undefined <- children("V40", defined = FALSE)
head(kids_with_undefined)
length(kids_with_undefined)
condense(kids, defined = FALSE)

# what happens if we have additional codes?
# (condense will warn if we don't explicitly ask to condense
# based on defined or possible codes.)
condense(c(kids, "41100"), warn = FALSE)

# a good use is to summarise the contents of a comorbidity:
icd9_map_elix$CHF
condense(icd9_map_elix$CHF, warn = FALSE)
# explaining big groups of codes takes advantage of this:
explain_code(icd9_map_elix$CHF, condense = TRUE, warn = FALSE)
# }

Run the code above in your browser using DataLab