Maybe something like this.
Notes:
- I have never used the geosphere package.
- I found the file of ZIP code latitude and longitude with a quick web search. I have no information about its quality
- I changed your tibble so that Destination.Zip is a character column and I added a leading zero to cases where the code as given only has four digits.
library(tidyr)
library(dplyr)
DF <- tibble::tribble(
~Origin.Zip, ~Destination.Zip,
"11235-5262", "08638",
"32714-4682", "08810",
"63031", "76140",
"85262-3135", "89015",
"75240-5654", "08638",
"93730-5151", "98443",
"47172-7801", "91761",
"92651-3471", "95691",
"11731-1623", "08638",
"95003-9613", "91730",
"12590", "77047",
"92122-1707", "11735",
"32812", "92865",
"77477", "91761",
"86001-5590", "59930",
"86001-5590", "59930",
"10901-7854", "08638",
"07302-2871", "08817",
"92657-1307", "92865",
"57252-5968", "91789",
"94588-3957", "77047",
"91001-2733", "01373",
"78572-8222", "91352",
"28348", "91752",
"73801", "28610"
)
DF <- separate(DF, Origin.Zip, into = c("Zip", "Route"))
#Data on ZIP code Lat. and Long. from https://gist.github.com/erichurst/7882666
ZIPS <- read.csv("US Zip Codes from 2013 Government Data",
colClasses = c("ZIP" = "character"))
DF <- inner_join(DF, ZIPS, by = c("Zip" = "ZIP"))
DF <- rename(.data = DF, LAT.Orig = LAT, LNG.Orig = LNG)
DF <- inner_join(DF, ZIPS, by = c("Destination.Zip" = "ZIP"))
DF
Orig <- as.matrix(select(DF, LNG.Orig, LAT.Orig))
Dest <- as.matrix(select(DF, LNG, LAT))
DF$Distance <- geosphere::distVincentyEllipsoid(p1 = Orig, p2 = Dest))