powered by
Return consistent version of a state abbreviations using stringr::str_*() functions. Letters are capitalized, all non-letters characters are removed, and excess whitespace is trimmed and squished, and then abbrev_full() is called with usps_state.
stringr::str_*()
abbrev_full()
normal_state( state, abbreviate = TRUE, na = c("", "NA"), na_rep = FALSE, valid = NULL )
A vector of normalized 2-digit state abbreviations.
A vector of US state names or abbreviations.
If TRUE (default), replace state names with the 2-digit abbreviation using the built-in state.abb and state.name vectors.
state.abb
state.name
A vector of values to make NA.
NA
logical; If TRUE, make all single digit repeating strings NA (removes valid "AA" code for "American Armed Forces").
TRUE
A vector of valid abbreviations to compare to and remove those not shared.
Other geographic normalization functions: abbrev_full(), abbrev_state(), check_city(), expand_abbrev(), expand_state(), fetch_city(), normal_address(), normal_city(), normal_zip(), str_normal()
abbrev_state()
check_city()
expand_abbrev()
expand_state()
fetch_city()
normal_address()
normal_city()
normal_zip()
str_normal()
normal_state( state = c("VT", "N/A", "Vermont", "XX", "ZA"), abbreviate = TRUE, na = c("", "NA"), na_rep = TRUE, valid = NULL )
Run the code above in your browser using DataLab