View source: R/NNCTFunctions.r
euc.dist | R Documentation |
Returns the Euclidean distance between x
and y
which can be vectors
or matrices or data frames of any dimension (x
and y
should be of same dimension).
This function is equivalent to Dist
function in the pcds
package but is
different from the dist
function in the stats
package of the standard R
distribution.
dist
requires its argument to be a data matrix and dist
computes and returns the distance matrix computed
by using the specified distance measure to compute the distances between the rows of a data matrix
(\insertCiteS-Book:1998;textualnnspat),
while euc.dist
needs two arguments to find the distances between.
For two data matrices A
and B
,
dist(rbind(as.vector(A),as.vector(B)))
and euc.dist(A,B)
yield the same result.
euc.dist(x, y)
x, y |
Vectors, matrices or data frames (both should be of the same type). |
Euclidean distance between x
and y
Elvan Ceyhan
dist
from the base package stats
and
Dist
from the package pcds
B<-c(1,0); C<-c(1/2,sqrt(3)/2); euc.dist(B,C); euc.dist(B,B); x<-runif(10) y<-runif(10) euc.dist(x,y) xm<-matrix(x,ncol=2) ym<-matrix(y,ncol=2) euc.dist(xm,ym) euc.dist(xm,xm) dat.fr<-data.frame(b=B,c=C) euc.dist(dat.fr,dat.fr) euc.dist(dat.fr,cbind(B,C))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.