dist2 | R Documentation |
Computes the Euclidean distances between all pairs of data point given
dist2(X, C)
X |
A data matrix where each row is a different data point |
C |
A data matrix where each row is a different data point. If this matrix is the same as X, pairwise distances for all data points are computed. |
Returns an N x M matrix where N is the number of rows in X and M is the number of rows in M. element (n,m) is the squared Euclidean distance between nth data point in X and mth data point in C
#load data data(data1) data(data2) # Calculate distance matrices(here we calculate Euclidean Distance, Dist1 = dist2(as.matrix(data1), as.matrix(data1)) Dist2 = dist2(as.matrix(data2), as.matrix(data2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.