title: Is there an R function or package that allows joining by columns with custom matching criteria, possibly via supplied functions?
body: <p>I want to join two tibbles that contain columns similar to this,</p>
  <pre><code>library(tidyverse)
  
  x &lt;- tibble(id = 1:7,
              my_col = c(NA, 
                         &quot;4352534j&quot;, 
                         &quot;0342852 02742t35&quot;,
                         &quot;971843 3245&quot;, 
                         &quot;804263&quot;, 
                         &quot;78asd1745&quot;,
                         &quot;87hn73&quot;))
  
  y &lt;- tibble(id = 1:6,
              other_col = c(&quot;taco232&quot;,
                            &quot;4352534j&quot;,
                            &quot;3245&quot;,
                            &quot;78asd1745&quot;,
                            &quot;0342852&quot;,
                            &quot;78asd1745&quot;))
  </code></pre>
  <p>such that the result is similar to this:</p>
  <pre><code># A tibble: 9 x 4
     id.x my_col            id.y other_col
    &lt;dbl&gt; &lt;chr&gt;            &lt;dbl&gt; &lt;chr&gt;    
  1     1 NA                  NA NA       
  2     2 4352534j             2 4352534j 
  3     3 0342852 02742t35     5 0342852  
  4     4 971843 3245          3 3245     
  5     5 804263              NA NA       
  6     6 78asd1745            4 78asd1745
  7     6 78asd1745            6 78asd1745
  8     7 87hn73              NA NA       
  9    NA NA                   1 taco232 
  </code></pre>
  <p>This can be done by (more or less) with a cartesian join followed by a filter, but that's less efficient. I am aware of <a href="https://cran.r-project.org/web/packages/fuzzyjoin/index.html" rel="nofollow noreferrer">fuzzy_join</a>, but I don't think that's exactly what I want (I could have missed something though).</p>
  <p>I would like to customize the criteria used to match the column values (keys) with each other. Perhaps this can be done with some package's &quot;full join&quot; function with a function argument that declares the matching rules. Here's an idea of how it could work (not necessarily how it <em>should</em> work):</p>
  <pre><code>match_criteria &lt;- function(colx, coly) {
    if (str_detect(colx, coly)) {
      return(1)
    } else {
      return(0)
    }
  }
  
  # fancy_full_join does not exist
  fancy_full_join(x, y, by = list(fun = match_criteria(&quot;my_col&quot;, &quot;other_col&quot;), 
                                  keep = &quot;both&quot;))
  </code></pre>
  <p>What is a solution that does this? It doesn't have to be on CRAN, but it seems like there'd already be a fairly simple conventional way to do it with data.table or dplyr.</p>