Creates n segments of a line (the RD cut-off) and assigns the closest border segment for each observation in the sf data frame. Computationally these tasks are quite demanding when the sample size is big and thus might take a few seconds to complete.

border_segment(data, cutoff, n = 10)

Arguments

data

sf data frame containing point data

cutoff

the RDD border in the form of a line (preferred) or borderpoints

n

the number of segments to be produced

Value

a vector with factors, each category representing one segment

Examples

points_samp.sf <- sf::st_sample(polygon_full, 100) # create points
# make it an sf object bc st_sample only created the geometry list-column (sfc):
points_samp.sf <- sf::st_sf(points_samp.sf)
points_samp.sf$segment10 <- border_segment(points_samp.sf, cut_off, 3)