title: merge data with partial match in r
body: <p>I have two datasets </p>
  
  <pre><code>datf1 &lt;- data.frame (name = c("regular", "kklmin", "notSo", "Jijoh",
   "Kish", "Lissp", "Kcn", "CCCa"),
   number1 = c(1, 8, 9,  2,  18, 25, 33,   8))
  #-----------
      name number1
  1 regular       1
  2  kklmin       8
  3   notSo       9
  4   Jijoh       2
  5    Kish      18
  6   Lissp      25
  7     Kcn      33
  8    CCCa       8
  
   datf2 &lt;- data.frame (name = c("reGulr", "ntSo", "Jijoh", "sean", "LiSsp",
   "KcN", "CaPN"),
     number2 = c(2, 8, 12,    13, 20, 18,   13))
  #-------------
     name number2
  1 reGulr       2
  2   ntSo       8
  3  Jijoh      12
  4   sean      13
  5  LiSsp      20
  6    KcN      18
  7   CaPN      13
  </code></pre>
  
  <p>I want to merge them by name column, however with partial match is allowed (to avoid hampering merging spelling errors in large data set and even to detect such spelling errors) and for example </p>
  
  <p>(1) If consecutive four letters (all if the number of letters are less than 4) at any position - match that is fine </p>
  
  <pre><code> ABBCD = BBCDK = aBBCD = ramABBBCD = ABB 
  </code></pre>
  
  <p>(2) Case sensitivity is off in the match e.g <code>ABBCD = aBbCd</code> </p>
  
  <p>(3) The new dataset will have both names (names from datf1 and datf2) preserved. So that letter we can detect if the match is perfect (may a separate column with how many letter do match) </p>
  
  <p>Is such merge possible ?</p>
  
  <p>Edits:</p>
  
  <pre><code>datf1 &lt;- data.frame (name = c("xxregular", "kklmin", "notSo", "Jijoh",
               "Kish", "Lissp", "Kcn", "CCCa"),
                       number1 = c(1, 8, 9,  2,  18, 25, 33,   8))
  datf2 &lt;- data.frame (name = c("reGulr", "ntSo", "Jijoh", "sean", 
               "LiSsp", "KcN", "CaPN"),
                       number2 = c(2, 8, 12,  13, 20, 18,   13))
  
  
  uglyMerge(datf1, datf2)
         name1  name2 number1 number2 matches
  1  xxregular   &lt;NA&gt;       1      NA       0
  2     kklmin   &lt;NA&gt;       8      NA       0
  3      notSo   &lt;NA&gt;       9      NA       0
  4      Jijoh  Jijoh       2      12       5
  5       Kish   &lt;NA&gt;      18      NA       0
  6      Lissp  LiSsp      25      20       5
  7        Kcn    KcN      33      18       3
  8       CCCa   &lt;NA&gt;       8      NA       0
  9       &lt;NA&gt; reGulr      NA       2       0
  10      &lt;NA&gt;   ntSo      NA       8       0
  11      &lt;NA&gt;   sean      NA      13       0
  12      &lt;NA&gt;   CaPN      NA      13       0
  </code></pre>