title: for every row in one data frame find the most similar row in another
body: <p>I have two data frames with Boolean values and numeric values. If needed the numeric values could be put into categories. </p>
  
  <pre><code>var1 &lt;- c(400,234,199,45,77,19)
  var2 &lt;- c(0,0,1,1,0,1)
  var3 &lt;- c(1,0,1,0,0,1) 
  df1 &lt;- data.frame(var1,var2,var3)
  var.1 &lt;- c(78,147,670,200,75,17)
  var.2 &lt;- c(0,0,0,1,1,1)
  var.3 &lt;- c(0,1,1,0,1,1) 
  df2 &lt;- data.frame(var.1,var.2,var.3)
  </code></pre>
  
  <p>I want to find in <code>df1</code> the most similar row in <code>df2</code>. </p>
  
  <p>I am aware of cluster analysis, which I could do for one data frame by itself, but once I have clusters for one data frame, how would I extract and apply the same clustering algorithm to the other data frame, so that both data frames are clustered in the same way? I also need as many "clusters" as rows in the data frame, which makes me think cluster analysis is not for this task. </p>
  
  <p>Additionally, every row in <code>df1</code> must be matched with only one row in <code>df2</code> so that at the end of the process every row in <code>df1</code> matches to a different row in <code>df2</code>. This is tricky, because if taking each row in isolation in <code>df1</code>, the same row in <code>df2</code> might get matched multiple times, which is not desired.   </p>