Learn R Programming

icd (version 4.0.6)

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, ...)

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

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

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.

...

arguments passed on to other functions

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 or 00010.

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 or 00010.

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 or 00010.

Methods (by class)

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

  • factor: Condense a factor of ICD codes

See Also

Other ICD-9 ranges: children, 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