dist_betw_arrays: Distance between rows of two arrays

Description Usage Arguments Details Value See Also Examples

View source: R/dist_betw_arrays.R

Description

Calculate the distances between the rows of two multi-dimensional arrays.

Usage

1
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 x.

distance

Indicates whether to use Euclidean distance ("rmsd" for root mean square difference), the mean absolute difference ("mad"), or the proportion of differences ("propdiff").

cores

Number of CPU cores to use, for parallel calculations. (If 0, use parallel::detectCores().) Alternatively, this can be links to a set of cluster sockets, as produced by parallel::makeCluster().

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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)

lineup2 documentation built on June 15, 2021, 9:07 a.m.