Skip to content

String search: Return "closest" match

1 message · Richard Cotton

#
additions.
The Levenshtein distance is a common metric for determining how close two 
string are (in fact, agrep uses this).  There's a function to calculate it 
on the R wiki.
http://wiki.r-project.org/rwiki/doku.php?id=tips:data-strings:levenshtein

You can use this to find the closest string.  (If your set of cities is 
large, it may be quickest to use agrep to narrow the selection first, 
since the pure R implementation of levenshtein is likely to be slow.)

Regards,
Richie.

Mathematical Sciences Unit
HSL


------------------------------------------------------------------------
ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}