title: merge by row.name and column
body: <p>This should be simple an I am probably just being silly but...
  I need to merge two data frames by the row names of df1 and a column in df2 i.e.</p>
  
  <pre><code>df1&lt;-data.frame(x=1:3,y=4:6) 
  rownames(df1)&lt;-c("a","b","c")
  df1
    x y
  a 1 4
  b 2 5
  c 3 6
  
  df2&lt;-data.frame(site=c("a","b"),p=5:6,q=10:11)
  df2
    site p  q
       a 5 10
       b 6 11
  </code></pre>
  
  <p>The merge should produce:</p>
  
  <pre><code>df3&lt;-data.frame(site=c("a","b"),p=5:6,q=10:11,x=1:2,y=4:5)
  df3
    site p  q x y
       a 5 10 1 4
       b 6 11 2 5
  </code></pre>
  
  <p>I have tried </p>
  
  <pre><code>merge(df1,df2,by.x=row.names(df1),by.y=df2$site) 
  </code></pre>
  
  <p>but get the error</p>
  
  <blockquote>
    <p>Error in fix.by(by.x, x) : 'by' must specify uniquely valid column(s)</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>