how to combine two data frames of different lengths? : <p>I have 2 data frames. Those are as follows:</p>

<pre><code>df1
Date    Duration
6/27/2014   10.00
6/30/2014   20.00
7/11/2014   15.00
</code></pre>

<p>and </p>

<pre><code>df2
Date    Percent_Removal
6/27/2014   20.39
6/30/2014   27.01
7/7/2014    49.84
7/11/2014   59.48
7/17/2014   99.04
</code></pre>

<p>I want to merge these 2 data frames based on the 'Date' column in df1. The output should look like this:</p>

<pre><code>df3
Date    Duration_sum    Percent_Removal
6/27/2014   10.00        20.39
6/30/2014   20.00        27.01
7/11/2014   15.00        59.48
</code></pre>

<p>I tried the following function:</p>

<pre><code>df1$Date &lt;- as.Date (df1$Date, format= "%m/%d/%Y")
df2$Date &lt;- as.Date (df2$Date, format= "%m/%d/%Y")
df3&lt;- as.data.frame (merge(df1,df2,by.x = "Date",all.x = TRUE))
</code></pre>

<p>My output is:</p>

<p>df3</p>

<pre><code> Date      Duration_sum   Percent_Removal
6/27/2014     10.00           NA
6/30/2014     20.00           NA
7/11/2014     15.00           NA
</code></pre>

<p>I will be highly grateful if someone can help me out with this problem. Thanks in advance.</p>
