Creates a function to get the mean minimum distance between two sets of points.

mean_dist_to(target, squared = TRUE)

Arguments

target

A data.frame with all numeric columns.

squared

Logical indicating whether to compute the mean squared distance (if TRUE) or the mean distance.

Value

A function that takes a data.frame with the same number of columns as target and then returns the mean minimum distance between them.

See also

Examples

target <- data.frame(x = rnorm(100), y = rnorm(100)) data <- data.frame(x = rnorm(100), y = rnorm(100)) distance <- mean_dist_to(target) distance(data)
#> [1] 0.1041971