Description Usage Arguments Details Value See Also Examples
View source: R/fetch_zones_three_digit.R
For a given 3-digit origin zip code, grab all destination zips and their corresponding zones. If a destination is supplied, the result is filtered to that origin-destination pair.
1 2 3 |
origin_zip |
(character) A single origin zip. If > 3 characters are supplied, the first 3 are used. If fewer, leading 0s are prepended. (E.g., "7" becomes "007".) |
destination_zip |
(character) Optional destination zip. Can be 3 or 5 characters. If not included, returns all possible destinations for the origin provided. |
exact_destination |
(boolean) If |
as_range |
(boolean) Should zones be shown with one row per zone (the default) or as one row per range of zips they apply to? |
show_details |
(boolean) Should columns with more details be retained?
Specifically: |
n_tries |
(numeric) How many times to try getting data if we're unsuccessful the first time. |
verbose |
(boolean) Message what's going on? |
Displays the result of a query what's shown on the "Get Zone Chart" tab of the USPS Zone Calc website. If you just want to supply two 5-digit zips and get a single zone back, use fetch_zones_five_digit
.
A tibble with origin zip and destination zips (in ranges or unspooled depending on as_range
) and the USPS zones the origin-destination pair corresponds to. If show_details
is TRUE, other columns are shown.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## Not run:
# All destination zips are returned for this origin
a_zip <- fetch_zones_three_digit("123")
nrow(a_zip)
# Only the zone corresponding to this origin and this destination are returned
fetch_zones_three_digit("123", "456", show_details = TRUE)
fetch_zones_three_digit("007", as_range = TRUE)
# Get multiple zips
c("897", "786") %>%
purrr::map_df(fetch_zones_three_digit)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.