Learn R Programming

icd (version 3.3)

sort_icd: Sort short-form ICD-9 codes

Description

Sorts lists of numeric only, V or E codes. Note that a simple numeric sort does not work for ICD-9 codes, since "162" > "1620", and also V codes precede E codes.

Usage

sort_icd(x, ...)

# S3 method for default sort_icd(x, short_code = guess_short(x), ...)

# S3 method for icd10 sort_icd(x, short_code = NULL, ...)

# S3 method for icd9 sort_icd(x, short_code = guess_short(x), ...)

icd_sort.default(...)

icd_sort.icd10(...)

icd_sort.icd9(...)

Arguments

x

vector of ICD codes to sort

...

arguments passed on to other functions

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

...

arguments passed on to other functions

...

arguments passed on to other functions

Value

sorted vector of ICD-9 codes. Numeric, then E codes, then V codes.

Methods (by class)

  • default: Guess whether ICD-9 or ICD-10 (or possibly sub-type in the future) then sort based on that type. ICD-10 codes, note that setting short is unnecessary and ignored.

  • icd10: Sort ICD-10 codes, note that setting short is unnecessary and ignored.

  • icd9: sort ICD-9 codes respecting numeric, then 'V', then 'E' codes, and accounting for leading zeroes. Will return a factor if a factor is given.

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.

Details

Implementation used fast built-in sort, then shuffles the E codes to the end.