Return consistent version US ZIP codes using stringr::str_*()
functions.
Non-number characters are removed, strings are padded with zeroes on the
left, and ZIP+4 suffixes are removed. Invalid ZIP codes from a vector can be
removed as well as single (repeating) character strings.
normal_zip(zip, na = c("", "NA"), na_rep = FALSE, pad = FALSE)
A vector of US ZIP codes.
A vector of values to pass to na_in()
.
logical; If TRUE
, na_rep()
will be called. Please note that
22222, 44444, and 55555 valid ZIP codes that will not be removed.
logical; Should ZIP codes less than five digits be padded with a leading zero? Leading zeros (as are found in New England ZIP codes) are often dropped by programs like Microsoft Excel when parsed as numeric values.
A character vector of normalized 5-digit ZIP codes.
Other geographic normalization functions:
abbrev_full()
,
abbrev_state()
,
check_city()
,
expand_abbrev()
,
expand_state()
,
fetch_city()
,
normal_address()
,
normal_city()
,
normal_state()
,
str_normal()