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.
icd_sort(x, ...)# S3 method for default
icd_sort(x, short_code = icd_guess_short(x), ...)
# S3 method for icd10
icd_sort(x, short_code = NULL, ...)
# S3 method for icd9
icd_sort(x, short_code = icd_guess_short(x), ...)
vector of ICD codes to sort
arguments passed on to other functions
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.
sorted vector of ICD-9 codes. Numeric, then E codes, then V codes.
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.
Implementation used fast built-in sort, then shuffles the E codes to the end.