zips: A .tab file of US ZIP code data for mapping recipients

Description Usage Format Details Note Source References Examples

Description

A .tab file of United States ZIP code data for mapping recipients. Called by zip.plot to match ZIP codes from letters to latitude and longitude coordinates, and then plot latitudes and longitudes on a user-selected map type.

Usage

1

Format

A data frame with 33309 observations on 4 variables.

state

a factor containing state and territory abbreviations (with levels AK, AL, ..., WY).

zip

a factor containing three-digit, four-digit, five-digit, and three-digit-plus-wildcard formatted ZIP codes (with 33188 levels).

lat

a numeric vector of latitude coordinates.

lon

a numeric vector of longitude coordinates.

Details

A few ZIP codes span more than one state, and thus appear more than once in zips. See the Examples below for hints on extracting latitude and longitude.

Note

Not all US ZIP codes are currently included in this file. If you have a ZIP code you would like included for plotting, please email the package maintainer with the following four pieces of information: the state in which the ZIP code is located, the ZIP code itself, the latitude of the ZIP code to six decimal places (such as 38.643248), and the longitude of the ZIP code to six decimal places (such as -75.611025). Please also provide the city and any other information required to verify the latitude and longitude for inclusion.

Source

The original file upon which zips.tab is based is available at http://www.census.gov/ tiger/tms/gazetteer/zcta5.txt, which is linked from http://www.census.gov/ geo/www/gazetteer/places2k.html. The US Census Bureau's Geography Division produced these documents. A few additions to the originals have been made. See the muRL CHANGELOG for details.

References

Further information about ZIP Code Tabulation Areas (ZCTAs) is available at

http://www.census.gov/geo/ZCTA/zcta.html.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data(zips)

summary(zips$lat)
summary(zips$lon)

## Extracting latitude and longitude.
## Create a sample survey data frame with an ID variable, 
##   respondent ZIP code, state, and survey response:
svy1 <- data.frame(id = c(1,2,3,4), zip = c("10001", "10001", "63130", "380HH"), 
          state = c("NY", "NY", "MO", "AR"), resp = c(1,2,1,5))
svy1
## Since ZIP 380HH spans three states, all are included:
svy2 <- merge(svy1, zips, by = "zip", all.x = TRUE) 
svy2
## Merging by ZIP and state omits the duplicate 380HH entries:
svy3 <- merge(svy1, zips, by = c("zip", "state"), all.x = TRUE)
svy3

Example output

Loading required package: maps
Loading required package: stringr
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  17.96   35.38   39.46   38.83   42.11   71.30 
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-176.64  -97.24  -88.33  -91.10  -80.39  106.67 
  id   zip state resp
1  1 10001    NY    1
2  2 10001    NY    2
3  3 63130    MO    1
4  4 380HH    AR    5
    zip id state.x resp state.y      lat       lon
1 10001  1      NY    1      NY 40.75074 -73.99653
2 10001  2      NY    2      NY 40.75074 -73.99653
3 380HH  4      AR    5      AR 35.63873 -89.85500
4 380HH  4      AR    5      KY 36.56724 -89.54227
5 380HH  4      AR    5      TN 35.85750 -89.74889
6 63130  3      MO    1      MO 38.66395 -90.32349
    zip state id resp      lat       lon
1 10001    NY  1    1 40.75074 -73.99653
2 10001    NY  2    2 40.75074 -73.99653
3 380HH    AR  4    5 35.63873 -89.85500
4 63130    MO  3    1 38.66395 -90.32349

muRL documentation built on June 20, 2017, 9:15 a.m.