Find the nearest neighbor for a set of data points

nn(p, y, q)

Arguments

p

matrix of variable values, each row is a data point

y

vector of values, each entry corresponds to one row in p

q

vector of variable values, each entry corresponds to one column of p

Value

an interpolated value for q

Details

nn finds the n-dimensional nearest neighbor for given datapoint

See also

Examples

p <- matrix(floor(runif(100, 0, 9)), 20)
y <- floor(runif(20, 0, 9))
q <- matrix(floor(runif(5, 0, 9)), 1)
nn(p, y, q)
#> [1] 8