You can do joins as well using Hadley Wickham's awesome dplyr package.
library(dplyr)
#make sure that CustomerId cols are both typethe numericsame type
#they ARE notaren’t usingin the provided codedata in(one questionis integer and dplyrone willis complaindouble)
df1$CustomerId <- as.numericdouble(df1$CustomerId)
df2$CustomerId <- as.numeric(df2$CustomerId)
Mutating joins: add columns to df1 using matches in df2
#inner
inner_join(df1, df2)
#left outer
left_join(df1, df2)
#right outer
right_join(df1, df2)
#alternate right outer
left_join(df2, df1)
#full join
full_join(df1, df2)
Filtering joins: filter out rows in df1, don't modify columns
semi_join(df1, df2) #keep only observations in df1 that match in df2.
anti_joinsemi_join(df1, df2) #drops
#drop all observations in df1 that match in df2.
anti_join(df1, df2)