Skip to contents

Parse Addresses

Usage

gc_address(data, address, city = NULL, zip = NULL, state = NULL, county = NULL)

Arguments

data

A data frame

address

The column containing the address. Can be a one-line address or just the street address component (if city, state, etc. are provided). Tidy-evaluated within data.

city

A column containing city names. Tidy-evaluated within data.

zip

A column containing ZIP codes. Tidy-evaluated within data.

state

A column containing states. Tidy-evaluated within data.

county

A column containing counties. Matched to an internal list and passed on to the output. Tidy-evaluated within data.

Value

A data frame containing columns with the parsed address. These match the Census format for street addresses.

Examples

gc_address(NULL, "125 5th St S St. Petersburg FL 33701")
#> # A tibble: 1 × 11
#>   state_code county_…¹ zip   city    num num_s…² stree…³ stree…⁴ stree…⁵ stree…⁶
#>   <chr>      <chr>     <chr> <chr> <int> <chr>   <chr>   <chr>   <chr>   <chr>  
#> 1 12         NA        33701 SAIN…   125 NA      NA      5TH     ST      S      
#> # … with 1 more variable: unit <chr>, and abbreviated variable names
#> #   ¹​county_code, ²​num_suff, ³​street_dir_pre, ⁴​street_name, ⁵​street_type,
#> #   ⁶​street_dir_suff
gc_address(NULL, "1225 St Charles St St Louis MO")
#> # A tibble: 1 × 11
#>   state_code county_…¹ zip   city    num num_s…² stree…³ stree…⁴ stree…⁵ stree…⁶
#>   <chr>      <chr>     <chr> <chr> <int> <chr>   <chr>   <chr>   <chr>   <chr>  
#> 1 29         NA        NA    SAIN…  1225 NA      NA      ST CHA… ST      NA     
#> # … with 1 more variable: unit <chr>, and abbreviated variable names
#> #   ¹​county_code, ²​num_suff, ³​street_dir_pre, ⁴​street_name, ⁵​street_type,
#> #   ⁶​street_dir_suff

data(nc_addr)
gc_address(nc_addr, address = address, city = city, zip = zip, county = county, state = "NC")
#> # A tibble: 1,000 × 11
#>    state_code county…¹ zip   city    num num_s…² stree…³ stree…⁴ stree…⁵ stree…⁶
#>    <chr>      <chr>    <chr> <chr> <int> <chr>   <chr>   <chr>   <chr>   <chr>  
#>  1 37         055      27948 KILL…   505 NA      NA      BURNS   DR      NA     
#>  2 37         055      27954 MANT…   144 NA      NA      PAYNE   RD      NA     
#>  3 37         055      27948 KILL…   116 NA      NA      MYBET   CT      NA     
#>  4 37         055      27949 KITT…  4516 NA      NA      MARITY… LN      NA     
#>  5 37         055      27959 NAGS…  2236 NA      S       CROATAN HWY     NA     
#>  6 37         055      NA    NA       NA NA      NA      NA      NA      NA     
#>  7 37         055      27954 MANT…   129 NA      NA      FIRST … CT      NA     
#>  8 37         055      NA    NA       NA NA      NA      NA      NA      NA     
#>  9 37         055      27949 KITT…  3634 NA      N       VA DARE TRL     NA     
#> 10 37         055      27948 KILL…  1911 NA      NA      HARBOU… DR      NA     
#> # … with 990 more rows, 1 more variable: unit <chr>, and abbreviated variable
#> #   names ¹​county_code, ²​num_suff, ³​street_dir_pre, ⁴​street_name, ⁵​street_type,
#> #   ⁶​street_dir_suff