Home   >   User Resources   >   Online Help   >   apaCharts.kNearestNeighbor
 

 

Function index Version 3.0.0

apaCharts.kNearestNeighbor(k, DataMatrix, Xidx, Yidx)

Excel=apaCharts.kNearestNeighbor(k, DataMatrix, Xidx, Yidx)

Result

Creates input data for a k-nearest-neighbor (kNN) chart: for each data point, its X and Y coordinates followed by those of its k nearest neighbors, with one chart series per data point. Cells without values contain #N/A.

Syntax

k: number of neighbors to consider, between 0 (data points only) and c - 1

DataMatrix: r x c matrix

Xidx: index of the x-dimension to plot

Yidx: index of the y-dimension to plot

Remarks

Neighbors are ranked by Euclidean distance; ties are broken by the lower column index. A data point is never its own neighbor, even if other data points have the same coordinates.

Pressing Esc aborts the calculation; the function then returns "Calculation aborted by user."