% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/facility_user_dist.R
\name{facility_user_dist}
\alias{facility_user_dist}
\title{facility_user_dist}
\usage{
facility_user_dist(facility, user, coverage_distance = 100,
  nearest = "facility")
}
\arguments{
\item{facility}{a dataframe containing columns named "lat", and "long".}

\item{user}{a dataframe containing columns "lat", and "long".}

\item{coverage_distance}{numeric indicating the coverage level for the
facilities to be within in metres to a user. Default value is 100 metres.}

\item{nearest}{character Can be "facility", "user", and "both". Defaults to
"facility". When set to "facility", returns a dataframe where every row
refers to every user, and the closest facility to each user. When set to
"user", it returns a dataframe where every row is every facility, and the
closest user to each facility. When set to "both", which will return every
pairwise combination of distances. Be careful when default is "facility".}
}
\value{
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.
}
\description{
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.
}
