Parse a prefix or suffix directional from a string. These data should be at the beginning or end of the string (i.e. the first/last word or two).
pm_streetDir_parse(.data, dictionary, locale = "us")
.data | A postmastr object created with pm_prep |
---|---|
dictionary | Optional; A tbl created with |
locale | A string indicating the country these data represent; the only current option is "us" but this is included to facilitate future expansion. |
A tibble with a new character variable pm.preDir
that contains
the abbreviation for the given directional for any prefix directional
and a second new character variable pm.sufDir
that contains the
abbreviation for the given directional for any suffix directional.
The use of abbrevations follows USPS addressing standards. If a prefix
or suffix direction is not detected in the string, a value of NA
will be returned. If no prefix directions are found in the data at all,
that column will not be returned; the same is true for suffix directions.
If a street name is also a directional, like North Ave
, it will be
identified and parsed as such. The pm_streetSuf_parse function includes
a logic check for streets that have a prefix direction but not street name
after the street suffix is parsed. If those conditions are met, the street name
will be changed from NA
to the directional's preferred spelling according
to the USPS.