Last data update: 2014.03.03

R: Compute Hamming distances
hamming.distanceR Documentation

Compute Hamming distances

Description

Compute the Hamming distance (the number of non-overlapping characters) between words of the same length.

Usage

hamming.distance(xsource, targets)

Arguments

xsource

A character string to compute the Hamming distance from.

targets

Words to which the Hamming distance must be computed. Must be of type character, or convertible to type character with as.character.

Details

The actual distance computation is performed by stringdist with "method='h'".

Value

An integer vector containing Hamming distances, with names corresponding to targets. Since the Hamming distances is only defined between words of the same length, the output of hamming.distance is only guaranteed to have the same length as targets if all targets have the same length as source.

Author(s)

Emmanuel Keuleers

References

Hamming, R. W. (1950). Error detecting and error correcting codes. Bell System technical journal, 29(2), 147-160.

See Also

stringdist, hamming.neighbors, coltheart.N

Examples

data(english.words)
targets<-english.words[which(nchar(english.words)==5)]
hamming.distance('electroencephalogram',english.words)

Results