sim2dist: Convert a similarity matrix into a distance matrix

Description Usage Arguments Value Examples

View source: R/sim2dist.R

Description

Convert a similarity matrix into a distance matrix.

Usage

1
sim2dist(sim, transformation = "1-x")

Arguments

sim

a similarity matrix of class "matrix" or "dist".

transformation

function or character. Transformation to apply to each element of the matrix.

Value

sim2dist returns an object of the same class as the input sim.

Examples

1
2
3
4
5
6
7
n <- 4
mat <- matrix(runif(n^2,-1, 1), ncol = n)
sim <- (mat + t(mat)) / 2
diag <- n * (seq_len(n) - 1) + seq_len(n)
sim[diag] <- 1
sim2dist(sim)
sim2dist(as.dist(sim), transformation = "1-absx")

abichat/correlationtree documentation built on March 11, 2020, 3:55 p.m.