Learn R Programming

supraHex (version 1.10.0)

sDistance: Function to compute the pairwise distance for a given data matrix

Description

sDistance is supposed to compute and return the distance matrix between the rows of a data matrix using a specified distance metric

Usage

sDistance(data, metric = c("pearson", "spearman", "kendall", "euclidean", "manhattan", "cos", "mi"))

Arguments

data
a data frame or matrix of input data
metric
distance metric used to calculate a symmetric distance matrix. See 'Note' below for options available

Value

  • dist: a symmetric distance matrix of nRow x nRow, where nRow is the number of rows of input data matrix

See Also

sDmatCluster

Examples

Run this code
# 1) generate an iid normal random matrix of 100x10
data <- matrix( rnorm(100*10,mean=0,sd=1), nrow=100, ncol=10)

# 2) calculate distance matrix using different metric
sMap <- sPipeline(data=data)
# 2a) using "pearson" metric
dist <- sDistance(data=data, metric="pearson")
# 2b) using "cos" metric
# dist <- sDistance(data=data, metric="cos")
# 2c) using "spearman" metric
# dist <- sDistance(data=data, metric="spearman")
# 2d) using "kendall" metric
# dist <- sDistance(data=data, metric="kendall")
# 2e) using "euclidean" metric
# dist <- sDistance(data=data, metric="euclidean")
# 2f) using "manhattan" metric
# dist <- sDistance(data=data, metric="manhattan")
# 2g) using "mi" metric
# dist <- sDistance(data=data, metric="mi")

Run the code above in your browser using DataLab