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")

Arguments

.data

A postmastr object created with pm_prep

dictionary

Optional; A tbl created with pm_dictionary to be used as a master list of directionals. If none is provided, the dic_us_dir object will be used as the default dictionary when locale = "us".

locale

A string indicating the country these data represent; the only current option is "us" but this is included to facilitate future expansion.

Value

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.

Details

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.