title: Is it possible to do a full join in dplyr and keep all the columns used in the join?
body: <p>I have two tables that I want to do a full join using dplyr, but I don't want it to drop any of the columns. Per the documentation and my own experience it is only keeping the join column for the left hand side. This is a problem when you have a row with a record for the right hand side since the join value is gone.</p>
  
  <p>For example, suppose I have the two tables a and b,</p>
  
  <pre><code>customerId | revenue               customerId | state
  -----------|---------              -----------|-------
      1      | 2000                       1     |  CA
      2      | 3000                       3     |  GA
      4      | 4000                       4     |  NY
  </code></pre>
  
  <p>doing something like <code>full_join(a, b, by="customerId")</code> will produce</p>
  
  <pre><code>customerId | revenue | state
  -----------|---------|-------
      1      |   2000  |  CA
      2      |   3000  | &lt;NA&gt;
     &lt;NA&gt;    |   &lt;NA&gt;  |  GA
      4      |   4000  |  NY
  </code></pre>
  
  <p>so there is no way to tell which customer that third row is from. The ideal output would be</p>
  
  <pre><code>customerId.a | customerId.b | revenue | state
  -------------|--------------|---------|-------
        1      |      1       |   2000  |  CA
        2      |     &lt;NA&gt;     |   3000  | &lt;NA&gt;
      &lt;NA&gt;     |      3       |   &lt;NA&gt;  |  GA
        4      |      4       |   4000  |  NY
  </code></pre>
  
  <p>note that this is just a toy example. I'm actually using sparklyr so this is all being run in Spark. Thus, merge won't work here for me. Is there a way to do what I'm looking for in dplyr?</p>
  
  <p>EDIT:
  As someone pointed out this actually is working as desired in dplyr itself locally. However, I do see this problem using sparklyr (which uses dplyr). Here is the code to see that:</p>
  
  <pre><code>library(sparklyr)
  sc &lt;- spark_connect("local[4]")
  d1 &lt;- data_frame(customerId = c("1","2","4"), revenue=c(2000,3000,4000))
  d2 &lt;- data_frame(customerId = c("1","3","4"), state=c("CA", "GA", "NY"))
  d1_tbl &lt;- copy_to(sc, d1)
  d2_tbl &lt;- copy_to(sc, d2)
  full_join(d1_tbl, d2_tbl, by=c("customerId"))
  </code></pre>