dist_betw_arrays {lineup2} | R Documentation |
Distance between rows of two arrays
Description
Calculate the distances between the rows of two multi-dimensional arrays.
Usage
dist_betw_arrays(x, y, distance = c("rmsd", "mad", "propdiff"), cores = 1)
Arguments
x |
A numeric array. |
y |
A second numeric array, with the same dimensions as |
distance |
Indicates whether to use Euclidean distance
( |
cores |
Number of CPU cores to use, for parallel calculations.
(If |
Details
The two arrays need to have the same dimensions, except for the
leading dimension (rows). They are turned into matrices by merging
all but the leading dimension, and then they're sent to
dist_betw_matrices()
.
Value
If x
and y
have m
and n
rows, respectively, 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
dist_betw_matrices()
, corr_betw_matrices()
Examples
p <- 10
k <- 6
n <- 5
m <- 3
x <- array(stats::rnorm(n*k*p), dim=c(n,k,p))
rownames(x) <- LETTERS[1:n]
y <- array(stats::rnorm(m*k*p), dim=c(m,k,p))
rownames(y) <- letters[1:m]
d <- dist_betw_arrays(x, y)