Euclid carries out the calculation of pairwise Euclidean
distances within a set of coordinates or between two sets thereof, with
Euclid(x, y, squared = FALSE)
A set of coordinates in the form of a
An optional second set of coordinates in the same dimensions as
Should the squared Euclidean distances be returned (default: FALSE).
When only one set of coordinates is given to the function (i.e.,
y is omitted), the function returns the pairwise
distances in the form of a 'dist-class' object representing a
lower-triangle matrix. If weights are omitted, the result is identical to
that produced by function dist with argument
method = "euclidean" (the function's default).
The standard 'R' function used to calculate the Euclidean distance
dist), only allows one to calculate pairwise distances between
the rows of a single matrix of Cartesian coordinates and return a
'dist-class' object, which is a one-dimensional array meant to be
interpreted as a lower-triangular matrix. Function
Euclid can also be
provided two data matrices (arguments
y) and output a
rectangular matrix of the Euclidean distances.
A 'dist-class' object or, whenever
y is provided,
matrix with as many rows as the number of rows in
and as many columns as the number of rows in
Guillaume Guenard and Pierre Legendre, Bertrand Pages Maintainer: Guillaume Guenard <email@example.com>
The 'dist-class' and associated methods.
## A set of reference points: x <- cbind(c(1,4,5,2,8,4), c(3,6,7,1,3,2)) dimnames(x) <- list(LETTERS[1:6], c("x", "y")) ## The pairwise Euclidean distances among the reference points: d1 <- Euclid(x) d1 ## That result is the same as that obtained from function dist: d2 <- dist(x, method = "euclidean") all(d1 == d2) ## A second set of points: y <- cbind(c(3,5,7), c(3,6,8)) dimnames(y) <- list(LETTERS[7:9], c("x", "y")) ## The distances between the points in y (rows) and x (columns): Euclid(x, y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.