dist_betw_matrices {lineup2} | R Documentation |
Distance between rows of two matrices
Description
Calculate the distances between the rows of one matrix and the rows of a second matrix.
Usage
dist_betw_matrices(
x,
y,
distance = c("rmsd", "mad", "propdiff"),
align_cols = TRUE,
cores = 1
)
Arguments
x |
A numeric matrix. |
y |
A second numeric matrix, with the same number of columns as |
distance |
Indicates whether to use Euclidean distance
( |
align_cols |
If TRUE, align the columns in the two matrices by the column names. |
cores |
Number of CPU cores to use, for parallel calculations.
(If |
Value
If x
is m
by p
and y
is n
by p
, then the result
is an m
by n
matrix whose (i,j)th element is the distance
between the ith row of x
and the jth row of y
.
See Also
corr_betw_matrices()
, dist_betw_arrays()
Examples
p <- 10
n <- 5
m <- 3
x <- matrix(stats::rnorm(n*p), ncol=p)
rownames(x) <- LETTERS[1:n]
y <- matrix(stats::rnorm(m*p), ncol=p)
rownames(y) <- letters[1:m]
d <- dist_betw_matrices(x, y)