Description Usage Arguments Details Value ICD-9 ICD-10-CM and ICD-10-BE Examples
The default method will guess whether ICD-9 or ICD-10 then sort
based on that type. For ICD-10 codes, note that setting short
is
unnecessary and ignored. All codes should consistently use the decimal
divider.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | sort_icd(x, decreasing = FALSE, short_code = guess_short(x), ...)
## S3 method for class 'icd10'
sort(x, decreasing = FALSE, ...)
## S3 method for class 'icd10cm'
sort(x, decreasing = FALSE, ...)
## S3 method for class 'icd10be'
sort(x, decreasing = FALSE, ...)
## S3 method for class 'icd9'
sort(x, decreasing = FALSE, short_code = guess_short(x), ...)
order.icd9(x, na.last = TRUE)
order.icd10cm(x)
order.icd10be(x)
|
x |
vector of ICD codes to sort or order |
decreasing |
Logical See |
short_code |
single logical value which determines whether the ICD-9
code provided is in short ( |
... |
arguments passed on to other functions |
na.last |
Logical, analogous to |
Note that sort
is an S3 generic, whereas
order
is not. Thus we export order.icd10cm
, but
not sort.icd10cm
, etc..
For sort, a sorted vector of ICD-9 codes. Numeric, then E codes, then V codes. For order, an integer vector is returned with the order of each code.
Sorts lists of numeric, 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. Numeric codes are first,
then ‘V’, then ‘E’. A factor is returned if a factor is
given.
There are some codes which are sequenced
out of lexicographic order, e.g., C7A
and C7B
are between
C80
and C81
; D3A
is between D48
and D49
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # order ICD-10-CM is not lexicographic:
codes <- as.icd10cm(c("C7A", "C79", "C80", "C81", "C7B"))
# as the class is set, use S3 dispatch to get the right answer
sort(codes)
# or call directly, but recall S3 dispatch will only work once 'icd' is
# attached using:
library(icd)
icd:::sort.icd10cm(c("C7A", "C79", "C80", "C81", "C7B"))
stopifnot(!identical(
order.icd10cm(as.character(codes)),
order(codes)
))
icd::order.icd9(c("V20", NA, "100", NA, "E998", "101"))
codes[order.icd10cm(codes)]
# Note that base::order does NOT do S3 dispatch, so the following does not work:
codes[order(codes)]
|
The 'icd9' package is deprecated, and should be removed to avoid conflicts with 'icd' . The 'icd' package up to version 2.1 contains tested versions of all the deprecated function names which overlap with those in the old 'icd9' package, e.g., 'icd9ComorbidAhrq' '. It is highly recommended to run the command: 'remove.packages("icd9")'
[1] "C7A" "C79" "C80" "C81" "C7B"
[1] "C7A" "C79" "C80" "C81" "C7B"
[1] 3 6 1 5 2 4
[1] "C7A" "C79" "C80" "C81" "C7B"
[1] "C7A" "C7B" "C79" "C80" "C81"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.