I have two datasets, one smaller dataset (4000 rows) that contains information about different stores with each shops lat/long coords and one large dataset(600K Rows) that contains information about people who live in the area with their lat/long coordinates. Im trying to find how many people live within a certain distance from each store. I also want to do this for multiple distances. IE- for every store find how many people live within 200 meters, 500 meters, 1KM, 2M from the store.
How can I go about doing this efficiently using R?
Brief pseudocode is below
for(store in stores){
for(distance in distances){
store[distance] <- find_people_within_distance(store,distance)
}
}
find_people_within_distance(store,distance){
# Return number of People in People dataset who's geocoordinates fall within the distance range from stores
}
Thanks!