Uses haversines formula to calculate the distance between lat/long co-ordinates of every facility and every user, returning a data_frame. You can think of "facilities" as something like mobile towers, police centres, or AED locations, and "users" as something like individual houses, crime locations, or heart attack locations. The motivating example for this function was finding the distance from Automatic Electronic Defibrillators (AEDs) to each Out of Hospital Cardiac Arrest (OHCA), where the locations for AEDs and OHCAs are in separate dataframes. Currently facifacility_user_dist makes the strict assumption that the facility and user dataframes have columns named aed_id, lat, and long, and ohca_id, lat, and long. This will be updated soon.

facility_user_dist(facility, user, coverage_distance = 100,
  nearest = "facility")



a dataframe containing columns named "lat", and "long".


a dataframe containing columns "lat", and "long".


numeric indicating the coverage level for the facilities to be within in metres to a user. Default value is 100 metres.


character Can be "facility", "user", and "both". Defaults to "facility". When set to "facility", returns a dataframe where every row is every crime, and the closest building to each crime. When set to "user", returns a dataframe where every row is every building, and the closest crime to each building. set to "both", which will return every pairwise combination of distances. Be careful whenDefault is "facility"


a data frame containing the two datasets joined together with columns named facility_id, lat_facility, long_facility, user_id, lat_user, long_user, distance in meters between each the given facility and user in a row.