abbrev_full {campfin} | R Documentation |
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, end = FALSE)
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., |
rep |
If |
end |
logical; if |
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
abbrev_full("MOUNT VERNON", full = c("MOUNT" = "MT"))
abbrev_full("123 MOUNTAIN ROAD", full = usps_street)
abbrev_full("123 MOUNTAIN ROAD", full = usps_street, end = TRUE)
abbrev_full("Vermont", full = state.name, rep = state.abb)