title: Using dplyr's rename() including variable names not in data set
body: <p>I am trying to transition some plyr code to dplyr, and getting stuck with the new functionality of rename() in dplyr. I'd like to be able to reuse a single rename() expression for a set of datasets with overlapping but not identical original names. For example, </p>
  
  <pre><code>sample1 &lt;- data.frame(A=1:10, B=letters[1:10])
  
  sample2 &lt;- data.frame(B=11:20, C=letters[11:20])
  </code></pre>
  
  <p>And then,</p>
  
  <pre><code> rename(sample1, var1 = A, var2 = B, var3 = C)
  </code></pre>
  
  <p>I would like the result to be that variable A is renamed var1, and B is renamed var2, not adding a var3 in this case. Instead, I get</p>
  
  <p>Error: Unknown variables: C.</p>
  
  <p>In contrast, the plyr syntax would let me use</p>
  
  <pre><code>rename(sample1, c("A" = "var1", "B" = "var2", "C" = "var3"))
  rename(sample2, c("A" = "var1", "B" = "var2", "C" = "var3"))
  </code></pre>
  
  <p>and not throw an error. Is there a way to get the same result in dplyr without getting the Unknown variables error?</p>