To return a value of TRUE
, (1) the first letter of abb
must match the
first letter of full
, (2) all letters of abb
must exist in full
, and
(3) those letters of abb
must be in the same order as they appear in
full
.
is_abbrev(abb, full)
A suspected abbreviation
A long form string to test against
logical; whether abb
is potential abbreviation of full
is_abbrev(abb = "BRX", full = "BRONX")
#> [1] TRUE
is_abbrev(abb = state.abb, full = state.name)
#> [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> [16] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> [31] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> [46] TRUE TRUE TRUE TRUE TRUE
is_abbrev(abb = "NOLA", full = "New Orleans")
#> [1] TRUE
is_abbrev(abb = "FE", full = "Iron")
#> [1] FALSE