R/ranges.R
expand_range.Rd
Great care is taken not to include codes which have children not in the
range. E.g., 100.9
to 101.1
would not include code
101
. See the extensive tests covering this area for much more detail.
expand_range(start, end, ...) # S3 method for character expand_range(start, end, short_code = NULL, defined = TRUE, ...) # S3 method for icd9 expand_range( start, end, short_code = guess_short(c(start, end)), defined = TRUE, ex_ambig_start = TRUE, ex_ambig_end = TRUE, ... ) start %i9da% end start %i9sa% end start %i9d% end start %i9mj% end start %i9s% end
start, end | 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., |
---|---|
short_code | single logical value which determines whether the ICD-9
code provided is in short ( |
defined | single logical value, if |
ex_ambig_start | single logical value, if |
ex_ambig_end | single logical, same as |
The default for the argument defined
is TRUE
since this is far
more likely to be useful to the end user, dealing with real ICD codes.
When the class is not known, it must be guessed from the start and end codes. If this guessing fails, e.g. start is ICD-9 whereas end is ICD-10, then an error is thrown. Otherwise, the appropriate S3 method is called.
character
: Expand a range of ICD-9 or ICD-10 codes when the
class is not known
icd9
: Expand a range of ICD-9 codes
expand_range("428.0", "428.9")#> [1] "428.0" "428.1" "428.2" "428.20" "428.21" "428.22" "428.23" "428.3" #> [9] "428.30" "428.31" "428.32" "428.33" "428.4" "428.40" "428.41" "428.42" #> [17] "428.43" "428.9""4280" %i9s% "4289"#> [1] "4280" "4281" "4282" "42820" "42821" "42822" "42823" "4283" "42830" #> [10] "42831" "42832" "42833" "4284" "42840" "42841" "42842" "42843" "4289""4280" %i9s% "42821"#> [1] "4280" "4281" "42820" "42821""42799" %i9sa% "42802" # doesn't include 428 or 4280#> [1] "42799" "42800" "42801" "42802""427.99" %i9da% "428.02"#> [1] "427.99" "428.00" "428.01" "428.02""V80" %i9s% "V810"#> [1] "V80" "V800" "V8001" "V8009" "V801" "V802" "V803" "V810"