Merge example

This is an example of how to use the function “Merge” in R.
Create a data frame 1:

df1 = data.frame(id=c(1:6),Product=c(rep("Toaster",3),rep("Radio",3)))

Create a second data frame:

df2 = data.frame(id=c(2,4,6),State=c(rep("Alabama",2),rep("Ohio",1)))
Now, merge both data frames:
both<-merge(df1, df2)
Another way to do it:
both<-merge(df1, df2, all.x=TRUE)
Yet another way:
both<-merge(df1, df2, all=FALSE)