powered by
This function takes two data frames or matrices and returns a matrix of pairwise Euclidean distances between the two.
pairDist(x1, x2 = NULL, na.rm = FALSE)
Matrix with nrow(x1) rows and nrow(x2) columns. Values are the distance between each row of x1 and row of x2.
nrow(x1)
nrow(x2)
x1
x2
Data frame or matrix one or more columns wide.
Data frame or matrix one or more columns wide. If NULL, then pairwise distances between all points in x1 are calculated.
NULL
Logical, if TRUE then any rows in x1 or x2 with at least one NA are removed first.
TRUE
NA
dist
x1 <- data.frame(x=sample(1:30, 30), y=sort(round(100 * rnorm(30))), z=sample(1:30, 30)) x2 <- data.frame(x=1:20, y=round(100 * rnorm(20)), z=sample(1:20, 20)) pairDist(x1, x2) pairDist(x1)
Run the code above in your browser using DataLab