Learn R Programming

BIDistances (version 0.1.3)

nearest: Nearest

Description

returns the index of the nearest neighbour of a given data point.

Usage

nearest(Data, i, defined)

Value

nNInd

The index of the nearest neighbour of data[i, ]

Arguments

Data

A matrix holding n data points as row vectors.

i

the index of the data point, who's nearest neighbour is sought.

defined

A row vector with 1 for all columns of data that are used for the computation. If missing, all columns are used.

Author

Michael Thrun, Raphael Paebst

Examples

Run this code
nearest(Data = as.matrix(iris[,1:4]), i = 1)

Run the code above in your browser using DataLab