hammingD {EnsCat} | R Documentation |
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.
hammingD(dat)
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). |
This function calculates the Hamming distance (normalized) between rows of the input data.
The result is a nxn matrix whose (i,j) element is the Hamming distance between rows i and j
See Also as alphadata,
### 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)