I have 2 data frames. Those are as follows:
df1
Date Duration
6/27/2014 10.00
6/30/2014 20.00
7/11/2014 15.00
and
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
I want to merge these 2 data frames based on the 'Date' column in df1. The output should look like this:
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
I tried the following function:
df1$Date <- as.Date (df1$Date, format= "%m/%d/%Y")
df2$Date <- as.Date (df2$Date, format= "%m/%d/%Y")
df3<- as.data.frame (merge(df1,df2,by.x = "Date",all.x = TRUE))
My output is:
df3
Date Duration_sum Percent_Removal
6/27/2014 10.00 NA
6/30/2014 20.00 NA
7/11/2014 15.00 NA
I will be highly grateful if someone can help me out with this problem. Thanks in advance.