R/zip_helper_functions.R
zip_distance.Rd
Calculate the distance between two ZIP codes in miles
zip_distance(zipcode_a, zipcode_b, lonlat = TRUE, units = "miles")
First vector of ZIP codes
Second vector of ZIP codes
lonlat argument to pass to raster::pointDistance() to select method of distance calculation. Default is TRUE to calculate distance over a spherical projection. FALSE will calculate the distance in Euclidean (planar) space.
Specify which units to return distance calculations in. Choices include meters or miles.
a data.frame containing a column for each ZIP code and a new column containing the distance between the two columns of ZIP code
zip_distance("08731", "08901")
#> zipcode_a zipcode_b distance
#> 1 08731 08901 40.7