as.dist.similarity: Converts a similarity matrix into a distance matrix.

Description Usage Arguments Details Value See Also Examples

View source: R/as.dist.similarity-functions.R

Description

This function converts a similarity matrix into a dist matrix.

Usage

1
2
3
  ## S3 method for class 'similarity'
 as.dist(m, diag = FALSE,
    upper = FALSE)

Arguments

m

matrix

diag

logical, should print.dist prints the diagonal?

upper

logical, should print.dist prints the upper triangel?

Details

To transform the similarity matrix into a distance matrix the following equation is used: d = sqrt{s[i,i] + s[j,j] - 2s[i,j]}

Value

an object of class dist.

See Also

dist, print.dist

Examples

1
2
3
4
5
6
library("similarity")

a <- matrix(c(1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1),
            ncol=3, nrow=4, byrow=TRUE)
s <- similarity(a, "jaccard")
as.dist(s)

sgibb/similarity documentation built on May 26, 2017, 6:56 a.m.