Create or use a named vector (c("abb" = "rep")) and pass it to stringr::str_replace_all(). The abb argument is surrounded with \\b to capture only isolated abbreviations. To be used inside normal_address() and normal_city() with usps_street and usps_city, respectively.

expand_abbrev(x, abb = NULL, rep = NULL)

Arguments

x

A vector containing abbreviations.

abb

One of three objects: (1) A dataframe with abbreviations in the first column and corresponding replacement strings in the second column; (2) a named vector, with abbreviations as names for their respective replacements (e.g., c("abb" = "rep")); or (3) an unnamed vector of abbreviations with an unnamed vector of replacements in the rep argument.

rep

If abb is an unnamed vector, a vector of replacement strings for each abbreviation in abb.

Value

The vector x with abbreviation replaced with their full version.

See also

Other geographic normalization functions: abbrev_full(), abbrev_state(), check_city(), expand_state(), fetch_city(), normal_address(), normal_city(), normal_state(), normal_zip(), str_normal()

Examples

expand_abbrev(x = "MT VERNON", abb = c("MT" = "MOUNT"))
#> [1] "MOUNT VERNON"
expand_abbrev(x = "VT", abb = state.abb, rep = state.name)
#> [1] "Vermont"
expand_abbrev(x = "Low FE Level", abb = tibble::tibble(x = "FE", y = "Iron"))
#> [1] "Low Iron Level"