Adds the Euclidean distance from every cell to the nearest cell whose
label is in labels (exact nearest-neighbour search). Cells carrying one
of these labels get self (0 by default) instead of the distance to
another such cell.
Usage
NearestLabelDistance(
cells,
labels,
column = "distance",
x = "x",
y = "y",
label = "label",
self = 0
)Examples
d <- data.frame(x = c(0, 3, 10), y = 0, label = c("t", "a", "a"))
NearestLabelDistance(d, "t", column = "dist")
#> x y label dist
#> 1 0 0 t 0
#> 2 3 0 a 3
#> 3 10 0 a 10