View source: R/dist_betw_arrays.R
dist_betw_arrays | R Documentation |
Calculate the distances between the rows of two multi-dimensional arrays.
dist_betw_arrays(x, y, distance = c("rmsd", "mad", "propdiff"), cores = 1)
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 |
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()
.
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
.
dist_betw_matrices()
, corr_betw_matrices()
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.