title: R: Using dplyr inside a function. exception in eval(expr, envir, enclos): unknown column
body: <p>I have created a function in R based on the <a href="https://stackoverflow.com/questions/29102155/r-string-fuzzy-matching-using-jarowinkler/29103325#29103325">kind help</a> of @Jim M.</p>
  
  <p>When i run the function i get the error: <strong>Error: unknown column 'rawdata'</strong>
  When looking at the debugger i get the message: <strong>Rcpp::exception in eval(expr, envir, enclos): unknown column 'rawdata'</strong></p>
  
  <p>However when i look at the environment window i can see 2 variables which I have passed to the function and they contain information rawdata with 7 level factors and refdata with 28 levels</p>
  
  <pre><code>function (refdata, rawdata)
  {
    wordlist &lt;- expand.grid(rawdata = rawdata, refdata = refdata,     stringsAsFactors = FALSE)
    wordlist %&gt;% group_by(rawdata) %&gt;% mutate(match_score =     jarowinkler(rawdata, refdata)) %&gt;%
  summarise(match = match_score[which.max(match_score)], matched_to = ref[which.max(match_score)])
  }
  </code></pre>