[R] k nearest neighbours between two matrix
Angel
angel_lul at hotmail.com
Wed Feb 25 11:58:20 CET 2004
I have two dataframes A and B consisting of latitude longitude coordinates
of points. For each point in A I want to find the k-nearest neighbours in B.
Currently, I calculate the distance from each point in A to all the points
in B (using rdist.earth() in fields package), sort the points of B by
distance and select the k nearest ones.
Is there a more efficient way to do this?
Function knearneigh {spdep} (using knn() of VR) does something similar but
for a matrix with itself and not with another matrix.
Is there a function that already does what I want and I could not find?
Thanks
Angel
More information about the R-help
mailing list