Skip to contents

In the york building and york crime context, writing nearest(york_crime,york) reads as "find the nearest crime in york to each building in york, and returns a dataframe with every building in york, the nearest york_crime to each building, and the distance in metres between the two."

Usage

coverage(nearest_df, to_df, distance_cutoff = 100, ...)

Arguments

nearest_df

dataframe containing latitude and longitude

to_df

dataframe containing latitude and longitude

distance_cutoff

integer the distance threshold you are interested in assessing coverage at

...

extra arguments to pass to nearest

Value

a dataframe containing information about the distance threshold uses (distance_within), the number of events covered and not covered (n_cov, n_not_cov), the percentage covered and not covered (pct_cov, pct_not_cov), and the average distance and sd distance.

Examples


library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union

# already existing locations
york_selected <- york |> filter(grade == "I")

# proposed locations
york_unselected <- york |> filter(grade != "I")
coverage(york_selected, york_crime)
#> # A tibble: 1 × 7
#>   distance_within n_cov n_not_cov prop_cov prop_not_cov dist_avg dist_sd
#>             <dbl> <int>     <int>    <dbl>        <dbl>    <dbl>   <dbl>
#> 1             100   339      1475    0.187        0.813    1400.   1597.
coverage(york_crime, york_selected)
#> # A tibble: 1 × 7
#>   distance_within n_cov n_not_cov prop_cov prop_not_cov dist_avg dist_sd
#>             <dbl> <int>     <int>    <dbl>        <dbl>    <dbl>   <dbl>
#> 1             100    54        17    0.761        0.239     120.    247.