title: Combine Dataframe based on value in row in R
body: <p>I have 5 dataframes each with a different number of rows. I need to merge them all together based on values in col1 of each dataframe. Observe</p>
  
  <pre><code>df1 &lt;- read.table(text="
     col1    col2
      A        5
      B        3
      C        6
      E        7", header=TRUE, stringsAsFactors=FALSE)
  
  df2 &lt;- read.table(text="
     col1    col2
      A        5
      B        6
      C       7
      M       8
      Z       9", header=T, stringsAsFactors=FALSE)
  </code></pre>
  
  <p>But I need it to produce:</p>
  
  <pre><code>   newdf
       col1    col2(#from df1)   col3(#from df2)
        A          5                  5
        B          3                  6
        C          6                  7  
        E          7                  0
        M          0                  8
        Z          0                  9
  </code></pre>
  
  <p>I have tried to merge a few at a time <code>by='col1'</code> but to no luck. Any tips?</p>
  
  <p>What I have tried:</p>
  
  <pre><code>posidf&lt;-merge(df1,df2,df3,df4,df5,all.x=TRUE)
  #wont execute
  posidf&lt;-merge(df1,df2,df3,df4,df5,by="col1",all.x=TRUE)
  #wont execute
  posidf&lt;-merge(df1,df2,df3,df4,df5,by="col1")
  Error in fix.by(by.x, x) : 
  'by' must specify one or more columns as numbers, names or logical
  </code></pre>