R: Find Nearest Neighbor Distances

neighbors {dissUtils} | R Documentation

## Find Nearest Neighbor Distances

### Description

Given one (or two) multivariate data sets, a difference method, and k neighbors to search for, `neighbors` finds the k points in the data set (or the second data set) that are closest to each point in the data set (or the first data set)

### Usage

    neighbors(X, Y = NULL, method = "euclidean", n.neighbors = 1, init.info = NULL)

### Arguments

`X` | a matrix of numeric values
`Y` | an optional second matrix that must have the same number of columns as `X`
`method` | one of the method choices from `diss`
`n.neighbors` | an integer between 1 and nrow(X) (or nrow(Y), if it is not null)
`init.info` | some difference methods require additional information. see `diss`

### Value

returns an `nrow(X)` by `n.neighbors` matrix of distances

[Package dissUtils version 1.0 Index]