Clusterize similar words / values in R
<p>Say I have the following variable</p>

<pre><code>ChicKen120
Chicken1.20
Chicken(1.20)
Cow
cow.
cow/
cat
</code></pre>

<p>As you can see there are many typos. 
What I would like to do is make groups of similar words and automatically redefine each group. </p>

<p>i.e. </p>

<pre><code>group 1 = "Cow", "cow", "cow/2

group 2 = "ChicKen120", "Chicken1.20"
</code></pre>

<p>After formatting each group, the end result will be </p>

<pre><code>chicken(1.20)
chicken(1.20)
chicken(1.20)
cow
cow
cow
cat
</code></pre>

<h2>My current progress</h2>

<p>I have found groups of similar words by using <code>adist()</code></p>

<pre><code>#Run adist on to find all words that are similar to another words. 
text &lt;- c("ChicKen120","Chicken1.20","Chicken(1.20)","Cow","cow.", "cow/", "cat")
    &gt; adist(text)
            [,1] [,2] [,3] [,4] [,5] [,6] [,7]
    [1,]    0    2    4    9    9    9    9
    [2,]    2    0    2   10    9   10   10
    [3,]    4    2    0   12   11   12   12
    [4,]    9   10   12    0    2    2    3
    [5,]    9    9   11    2    0    1    3
    [6,]    9   10   12    2    1    0    3
    [7,]    9   10   12    3    3    3    0
</code></pre>

<p>As you can see, similar words have a distance of less than 4 and dissimilar words have a distance of more than 4. </p>

<p>How can I clusterize these results into groups which can then be redefined? </p>

<p>For example, I've was given the following piece of advice:<br>
<em>"I used lapply() and unique() to clusterize this feature. After it, I just look for centroids and used table() for scoring, like a retrieve internet information system does. For example:</em></p>

<p><em>"chocolate", "chcolate", "chocolatebar", "choc bar", "chocolate bar" are all automatically reidentified as 'chocolate'.</em></p>

<p><em>All of this was done with native library."</em></p>

<p>However, I am a beginner in R and a layman in mathematics so i'm not sure how to approach the clustering and re-defining of groups.</p>