Returns a function that checks whether the Manhattan distance between two
numeric vectors is less than or equal to a given threshold.
Arguments
- dist
threshold above which the function will return FALSE
Value
function that checks if Manhattan distance between two vectors
exceeds dist
Examples
# test data: Manhattan distance equals 2
x <- rep(0, 5)
y <- c(0, 1, 0, 0, 1)
# should return TRUE when checking Manhattan distance <= 3
dist_3 <- manhattan(3)
dist_3(x, y)
#> [1] TRUE
# should return FALSE when checking Manhattan distance <= 1
dist_1 <- manhattan(1)
dist_1(x, y)
#> [1] FALSE