Learn R Programming

PerMallows (version 1.13)

distance: Compute the distance between permutations

Description

Compute the distance between two given permutations. If only one permutation is given the other one is assumed to be the identity (1,2,3,....,n) The distance can be kendall, cayley, hamming and ulam

Usage

distance(perm1, perm2 = identity.permutation(length(perm1)),
  dist.name = "kendall")

Arguments

perm1
a permutation
perm2
optional a permutation
dist.name
optional. One of: kendall (default), cayley, hamming, ulam

Value

The distance between the permutations

Examples

Run this code
distance(c(1,2,3,5,4))
distance(c(1,2,3,5,4), c(1,2,3,5,4))
distance(c(1,2,3,5,4), c(1,4,2,3,5), "cayley")

Run the code above in your browser using DataLab