R/nearest.R

nearest <- function (Data, i, defined) {
  #MT: Korrektur fuer Standardfall
  if(missing(defined)){
    defined = rep(1, ncol(Data))
  }
  distList = Dist2All(Data[i,], Data, defined, knn=2)
  nnind = distList[[2]][2] # nearest neighbor is the point itself, so choose second nearest neighbor
  return(nnind = nnind)
}

Try the BIDistances package in your browser

Any scripts or data that you put into this service are public.

BIDistances documentation built on June 8, 2025, 10:01 a.m.