hammingD: Calculate the hamming distance between data points.

Description Usage Arguments Details Value See Also Examples

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

1
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

1
2
3
4
5
6
7
8
9
### 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)

Example output

Loading required package: dendextend

---------------------
Welcome to dendextend version 1.5.2
Type citation('dendextend') for how to cite the package.

Type browseVignettes(package = 'dendextend') for the package vignette.
The github page is: https://github.com/talgalili/dendextend/

Suggestions and bug-reports can be submitted at: https://github.com/talgalili/dendextend/issues
Or contact: <tal.galili@gmail.com>

	To suppress this message use:  suppressPackageStartupMessages(library(dendextend))
---------------------


Attaching package: 'dendextend'

The following object is masked from 'package:stats':

    cutree

Loading required package: ggplot2
Loading required package: ggdendro

Attaching package: 'ggdendro'

The following object is masked from 'package:dendextend':

    theme_dendro

Loading required package: seqinr

EnsCat documentation built on May 1, 2019, 8:45 p.m.