rdist {fields} | R Documentation |
Given two sets of locations computes the Euclidean distance matrix among all pairings.
rdist(x1, x2)
x1 |
Matrix of first set of locations where each row gives the coordinates of a particular point. |
x2 |
Matrix of second set of locations where each row gives the coordinates of a particular point. If this is missing x1 is used. |
Let D be the mXn distance matrix. The elements are the Euclidean distances between the all locations x1[i,] and x2[j,].
D.ij = sqrt( sum.k (( x1[i,k] - x2[j,k]) **2 ).
The distance matrix if nrow(x1)=m and nrow( x2)=n then the returned matrix will be mXn.
exp.cov, rdist.earth
out<- rdist( ozone$x) # out is a 20X20 matrix. out2<- rdist( ozone$x[1:5,], ozone$x[11:20,]) #out2 is a 5X10 matrix