[R] shortest distance between two point pattern
huber at ebi.ac.uk
Sat Feb 9 17:23:50 CET 2008
there is also the function "matchpt" in the Biobase package (in
Bioconductor) that seems to do what you want (in n dimensions).
It's written in C, and the implementation is simple and of complexity
n*m. (For larger problems, there are more efficient nearest neighbor
search algorithms, but I am not aware whether or where in R.). This one
works well for medium sized problem as in your example.
Wolfgang Huber EBI/EMBL Cambridge UK http://www.ebi.ac.uk/huber
Milton Cezar Ribeiro scripsit:
> Hi R-experts.
> I am working in a R-code where I have two datasets with x and y coordinates on each dataset.
> I intent to identify the shortest distance between this two datasets. I wrote a short code to do that.
> But when I join the datasets to compute the distances, the merge function run so slowly.
> I need only to identify the index of rows from each dataset related to the shortest distance.
> #merge two data.frames of points
> #### IT SPEND many time
> #compute distances between each pair of points
> #identify the minimum distance
> #select the pair of points (x0,y0,x1,y1) with shortest distance
> #trace a arrow between the points with shortest distance
> Any help are welcome
More information about the R-help