title: R Function to Replace SPEDIS in SAS
body: <p>SPEDIS Function in SAS calculates cost as follows (Example): </p>
  
  <p>Example</p>
  
  <pre><code>data words;
  input Operation $ Query $ Keyword $;
  Distance = spedis(query,keyword);
  Cost = distance * length(query);
  datalines;
  
  match       fuzzy        fuzzy
  singlet     fuzy         fuzzy
  doublet     fuuzzy       fuzzy
  swap        fzuzy        fuzzy
  truncate    fuzz         fuzzy
  append      fuzzys       fuzzy
  delete      fzzy         fuzzy
  insert      fluzzy       fuzzy
  replace     fizzy        fuzzy
  firstdel    uzzy         fuzzy
  firstins    pfuzzy       fuzzy
  firstrep    wuzzy        fuzzy
  several     floozy       fuzzy
  ;
  proc print data = words;
  run;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/hr9ni.png" alt="enter image description here"></p>
  
  <p>I am looking for R function which does exactly same thing. Need Help.</p>