title: How to specify names of columns for x and y when joining in dplyr?
body: <p>I have two data frames that I want to join using dplyr. One is a data frame containing first names.</p>
  
  <pre><code>test_data &lt;- data.frame(first_name = c("john", "bill", "madison", "abby", "zzz"),
                          stringsAsFactors = FALSE)
  </code></pre>
  
  <p>The other data frame contains a cleaned up version of the Kantrowitz names corpus, identifying gender. Here is a minimal example:</p>
  
  <pre><code>kantrowitz &lt;- structure(list(name = c("john", "bill", "madison", "abby", "thomas"), gender = c("M", "either", "M", "either", "M")), .Names = c("name", "gender"), row.names = c(NA, 5L), class = c("tbl_df", "tbl", "data.frame"))
  </code></pre>
  
  <p>I essentially want to look up the gender of the name from the <code>test_data</code> table using the <code>kantrowitz</code> table. Because I'm going to abstract this into a function <code>encode_gender</code>, I won't know the name of the column in the data set that's going to be used, and so I can't guarantee that it will be <code>name</code>, as in <code>kantrowitz$name</code>.</p>
  
  <p>In base R I would perform the merge this way:</p>
  
  <pre><code>merge(test_data, kantrowitz, by.x = "first_names", by.y = "name", all.x = TRUE)
  </code></pre>
  
  <p>That returns the correct output:</p>
  
  <pre><code>  first_name gender
  1       abby either
  2       bill either
  3       john      M
  4    madison      M
  5        zzz   &lt;NA&gt;
  </code></pre>
  
  <p>But I want to do this in dplyr because I'm using that package for all my other data manipulation. The dplyr <code>by</code> option to the various <code>*_join</code> functions only lets me specify one column name, but I need to specify two. I'm looking for something like this:</p>
  
  <pre><code>library(dplyr)
  # either
  left_join(test_data, kantrowitz, by.x = "first_name", by.y = "name")
  # or
  left_join(test_data, kantrowitz, by = c("first_name", "name"))
  </code></pre>
  
  <p>What is the way to perform this kind of join using dplyr?</p>
  
  <p>(Never mind that the Kantrowitz corpus is a bad way to identify gender. I'm working on a better implementation, but I want to get this working first.)</p>