threshold_distance2: threshold_distance2

View source: R/distance.r

threshold_distance2R Documentation

threshold_distance2

Description

Computes the distance between rows of left_df (old data) and right_df (new data) and returns those that fall below threshold.

Usage

threshold_distance2(
  left_df,
  right_df,
  threshold,
  cols = c("x", "y"),
  id_col = "ID",
  extra_columns = NULL,
  as_dataframe = FALSE,
  check_id = FALSE,
  distance_type = c("euclidean", "haversine")
)

Arguments

left_df

data.frame old data to compare distances to

right_df

data.frame new data to check for points in left_df that are nearby

threshold

Maximum distance to return

cols

Names of columns of numeric data. The data will first be sorted on the first of these.

id_col

Name of column holding ID data

extra_columns

Names of other columns to expand into the results based on indices.

as_dataframe

logical if a list (default) or data.frame should be returned

check_id

Whether the ID variable should be checked for inclusion

distance_type

What distance function to use

Value

Either a list or data.frame showing which IDs matched with other IDs, the distance between them and the rows numbers where the pairs occured.

Author(s)

Michael Beigelmacher

Examples

left_df <- data.frame(
x = c(0, 1, 1, 0),
y = c(0, 1, 3, 2)
)

right_df <- data.frame(
   x = c(0, 0, 2),
   y = c(1, 3, 2)
)

threshold_distance2(left_df, right_df, threshold = 1.5, as_dataframe=FALSE)
threshold_distance2(left_df, right_df, threshold = 1.5, as_dataframe=TRUE)

jaredlander/distancethreshold documentation built on June 10, 2025, 1:56 a.m.