Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

nearest.neighbours

Nearest neighbour structure for a data set


Description

This function can be used to generate nearest neighbour information for a set of 2D data points.

Usage

nearest.neighbours(x, y)

Arguments

x

vector containing x ccordinates of points.

y

vector containing x ccordinates of points.

Details

The C++ implementation of this function is used inside the locpoly and interp functions.

Value

A list with two components

index

A matrix with one row per data point. Each row contains the indices of the nearest neigbours to the point associated with this row, currently the point itself is also listed in the first row, so this matrix is of dimension n times n (will change to n times n-1 later).

dist

A matrix containing the distances according to the neigbours listed in component index.

Author(s)

Albrecht Gebhardt <albrecht.gebhardt@aau.at>, Roger Bivand <roger.bivand@nhh.no>

See Also

Examples

data(franke)
## use only a small subset
fd <- franke$ds1[1:5,]
nearest.neighbours(fd$x,fd$y)

interp

Interpolation Methods

v1.0-33
GPL (>= 2)
Authors
Albrecht Gebhardt [aut, cre, cph] (...), Roger Bivand [aut], David Sinclair [aut, cph]
Initial release
2020-01-07

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.