pairDist: Calculate pairwise distances between two matrices or data...

pairDistR Documentation

Calculate pairwise distances between two matrices or data frames.

Description

This function takes two data frames or matrices and returns a matrix of pairwise Euclidean distances between the two.

Usage

pairDist(x1, x2 = NULL, na.rm = FALSE)

Arguments

x1

Data frame or matrix one or more columns wide.

x2

Data frame or matrix one or more columns wide. If NULL, then pairwise distances between all points in x1 are calculated.

na.rm

Logical, if TRUE then any rows in x1 or x2 with at least one NA are removed first.

Value

Matrix with nrow(x1) rows and nrow(x2) columns. Values are the distance between each row of x1 and row of x2.

See Also

dist

Examples


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)


adamlilith/omnibus documentation built on April 12, 2024, 8:46 p.m.