Learn R Programming

campfin (version 1.0.7)

abbrev_full: Abbreviate full strings

Description

Create or use a named vector (c("full" = "abb")) and pass it to stringr::str_replace_all(). The full argument is surrounded with \\b to capture only isolated intended full versions. Note that the built-in usps_street, usps_city, and usps_state dataframes have the columns reversed from what this function needs (to work by default with the counterpart expand_abbrev()).

Usage

abbrev_full(x, full = NULL, rep = NULL)

Arguments

x

A vector containing full words.

full

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

rep

If full is an unnamed vector, a vector of abbreviations strings for each full word in abb.

Value

The vector x with full words replaced with their abbreviations.

See Also

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

Examples

Run this code
# NOT RUN {
abbrev_full("MOUNT VERNON", full = c("MOUNT" = "MT"))
abbrev_full("Vermont", full = state.name, rep = state.abb)
abbrev_full("Low Iron Level", full = tibble::tibble(y = "Iron", x = "FE"))
# }

Run the code above in your browser using DataLab