I have a large matrix that is calculating the distance between two different zip codes (using rgeosphere
package). I would like to run a function that finds all zip code pairings that are <=x distance away from each other and create a list of them. The data looks like this:
91423 92231 94321
90034 3 4.5 2.25
93201 3.75 2.5 1.5
94501 2 6 0.5
So if I ran the function to extract all zip code pairings that are <2 miles away I would end up with these zip codes:
94321
94321
93201
94501
The goal is basically to identify all adjacent zip codes in the US to a list of zip codes I have. If there is a better way to do this I am open to suggestions.