An addr vector is created by converting messy, real-world mailing addresses in a
character vector into a list of standardized address tags that behaves like a vector.
addr() (and as_addr()) vectors are a list of address tags under the hood, constructed
by tagging address components using addr_tag() and combining them into specific fields:
street_number:AddressNumberstreet_name:StreetNamePreType,StreetNamePreDirectional,StreetNamestreet_type:StreetNamePostType,StreetNamePostDirectionalcity:PlaceNamestate:StateNamezip_code:ZipCode
Usage
addr(
x = character(),
clean_address_text = TRUE,
expand_street_type = TRUE,
abbrev_cardinal_dir = TRUE,
clean_zip_code = TRUE
)
as_addr(x, ...)Arguments
- x
a character vector of address strings
- clean_address_text
logical; use
clean_address_text()to clean address text prior to tagging?- expand_street_type
logical; use
expand_post_type()to expandStreetNamePostTypetags? (e.g., "Ave" -> "Avenue")- abbrev_cardinal_dir
logical; abbreviate cardinal directions? (e.g., "west" -> "w")
- clean_zip_code
logical; remove any non-digit (or hyphen) characters and truncate tagged ZIP Code to 5 characters?
- ...
used to pass arguments in
as_addrto underlyingaddr()
Details
In addition to the cleaning steps described in the arguments, the street number is coerced
to a numeric after removing non-numeric characters.
See addr_tag() for details on address component tagging.
In the case of an address having more than one word for a tag (e.g., "Riva Ridge" for StreetName),
then these are concatenated together, separated by a space in the order they appeared in the address.
Compared to using addr(), as_addr() processes input character strings such that
parsing is done once per unique input, usually speeding up address parsing in real-world
datasets where address strings are often duplicated across observations.
Examples
as_addr(c("3333 Burnet Ave Cincinnati OH 45229", "1324 Burnet Ave Cincinnati OH 45229"))
#> 3333 Burnet Avenue Cincinnati OH 45229 1324 Burnet Avenue Cincinnati OH 45229