Skip to contents

This function loads a specific label data set that can be used to label five or three-digit ZIP codes in a data frame.

Usage

zi_load_labels(source = "UDS", type = "zip5", include_scf = FALSE,
    vintage = 2022)

Arguments

source

A required character scalar; specifies the source of the label data. The only supported sources are 'UDS' (default) and 'USPS'.

type

A required character scalar; one of either 'zip3' or 'zip5'. The 'zip3' type is only available from the 'USPS' source, while the 'zip5' type is available from 'UDS'.

include_scf

A logical scalar required when source = 'USPS' and type = 'zip3'; specifying whether to include the SCF (Sectional Center Facility) ID in the output. The default is FALSE.

vintage

A required character or numeric scalar; specifying the date for source = 'USPS' or the year of the data for source = 'UDS'. The zip_load_labels_list() function can be used to see available date values for source = 'USPS'.

Value

A tibble with the specified label data for either five or three-digit ZIP Codes.

Details

Labels are approximations of the actual location of a ZIP Code. For five-digit ZIP Codes, the city and state may or may not correspond to an individuals' mailing address city (since multiple cities may be accepted as valid by USPS for a particular ZIP Code) or state (since ZIP Codes may cross state lines).

For three-digit ZIP Codes, the area and state may or may not correspond to an individuals' mailing address state (since SCFs cover multiple states). For example, the three digit ZIP Code 010 covers Western Massachusetts in practice, but is assigned to the state of Connecticut.

Examples

# \donttest{
  # zip5 labels via UDS
  zi_load_labels(source = "UDS", type = "zip5", vintage = 2022)
#> # A tibble: 41,053 × 4
#>    zip5  label_city label_state label_type                          
#>    <chr> <chr>      <chr>       <chr>                               
#>  1 00501 Holtsville NY          Post Office or large volume customer
#>  2 00544 Holtsville NY          Post Office or large volume customer
#>  3 00601 Adjuntas   PR          Zip Code Area                       
#>  4 00602 Aguada     PR          Zip Code Area                       
#>  5 00603 Aguadilla  PR          Zip Code Area                       
#>  6 00604 Aguadilla  PR          Post Office or large volume customer
#>  7 00605 Aguadilla  PR          Post Office or large volume customer
#>  8 00606 Maricao    PR          Zip Code Area                       
#>  9 00610 Anasco     PR          Zip Code Area                       
#> 10 00611 Angeles    PR          Post Office or large volume customer
#> # ℹ 41,043 more rows

  # zip3 labels via USPS
  zi_load_labels(source = "USPS", type = "zip3", vintage = 202408)
#> # A tibble: 931 × 3
#>    zip3  label_area label_state
#>    <chr> <chr>      <chr>      
#>  1 005   MID-ISLAND NY         
#>  2 006   SAN JUAN   PR         
#>  3 007   SAN JUAN   PR         
#>  4 008   SAN JUAN   PR         
#>  5 009   SAN JUAN   PR         
#>  6 010   HARTFORD   CT         
#>  7 011   HARTFORD   CT         
#>  8 012   HARTFORD   CT         
#>  9 013   CENTRAL    MA         
#> 10 014   CENTRAL    MA         
#> # ℹ 921 more rows
# }