# NOT RUN {
# 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)]
# }
Run the code above in your browser using DataLab