pairwise_diff: Calculate the pairwise difference of all combinations in row...

View source: R/pairwise.R

pairwise_diffR Documentation

Calculate the pairwise difference of all combinations in row or column of a matrix.

Description

Calculate the pairwise difference of all combinations in row or column of a matrix.

Usage

pairwise_diff(X, margin = c(1, 2), na.rm = FALSE)

Arguments

X

a matrix

margin

row (1) or column (2) to apply the function

na.rm

logical. Should missing values (including NaN) be removed?

Value

a matrix with the same number of row (margin = 1) or column (margin = 2) with the original matrix.

Examples

X <- matrix(c(1, 2, 3, 4,
              1, 2, 5, 6,
              1, 2, 5, 7), nrow = 4)
pairwise_diff(X, 2)

byzheng/myutils documentation built on Oct. 3, 2024, 1:35 a.m.