Skip to content
Prev 275564 / 398506 Next

merging two dataframes

I think you want something like this (I like to be explicit about what you are merging)

df3 = merge(df1, df2, by = "date", all=T)

You can be explicit about what you are merging on in each file:

df3 = merge(df1,df2, by.x = "date?, by.y="date", all=T)

You were trying to merge on ?date1? but it looks to me like your data frames actually contains columns called ?date? not ?date1"

As Petr says, in the vanilla situation where there is no overlap of data and the ID column has the same name in both frames, then 
merge(frame1, frame2) works by itself.

tip: don?t use words like ?data? as variable names, as that is also a function
On 26 Oct 2011, at 11:59 AM, dividend wrote: