hammingD {EnsCat}R Documentation

Calculate the hamming distance between data points.

Description

Hamming distance is defined on categorical vectors. It counts the number of times the coordinates in two data vectors differ, or the number of substitutions required to convert one data vector into the other. Here the Hamming distance is normalized, so the result is the number of coordinates that differ divided by the vector length.

Usage

hammingD(dat)

Arguments

dat

dat should be a matrix or data frame of data. n is the number of observations (rows) and p is the number of dimensions (columns).

Details

This function calculates the Hamming distance (normalized) between rows of the input data.

Value

The result is a nxn matrix whose (i,j) element is the Hamming distance between rows i and j

See Also

See Also as alphadata,

Examples

### The running is time consuming
### Run hamming distance
#dis0<-hammingD(alphadata)
### Save as distance format
#REDIST<-as.dist(dis0)
### Run a hierarchical clustering using average linkage
#hc0 <- hclust(REDIST,method = "average")
### plot the dendrogram
#plot(hc0,label=xlab1,hang =-1)

[Package EnsCat version 1.1 Index]