[R] 'distance' between a vector and a permutation of the vector
Rajarshi Guha
rguha at indiana.edu
Tue Mar 18 00:25:25 CET 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi, I've been trying to identify a good way to do the following:
Say I have a vector of unique, integers
x <- c(1,3,2,4,5)
I then have a permuted version of the above vector, say
y <- c(1,3,5,2,4)
Is there an easy way to get the "distance" between the two vectors.
The sense I'm thinking of is such, that if we have
y <- c(1,3,2,5,4)
then this is 'closer' to x, since there is only one pair that is mis-
ordered, compared to something like
y <- c(1,5,3,4,2)
It seems that a good candidate would be the levenstein distance - is
there a function that would work on vectors of integers rather than
strings? Are there more suitable candidates?
Thanks for any pointers
- -------------------------------------------------------------------
Rajarshi Guha <rguha at indiana.edu>
GPG Fingerprint: D070 5427 CC5B 7938 929C DD13 66A1 922C 51E7 9E84
- -------------------------------------------------------------------
Q: What's polite and works for the phone company?
A: A deferential operator.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)
iEYEARECAAYFAkfe/eUACgkQZqGSLFHnnoSyVwCfVi8eLnXy1eCYfAwOEF2F93cJ
1BUAoPD9vTagEGNKom5hCuR8ppb0bVgZ
=hbc7
-----END PGP SIGNATURE-----
More information about the R-help
mailing list