I have two dataframes (df1 and df2) in R that I am trying to join. Neither have the same unique column, but they do both share a name column. Here is a snippet of each data frame:
df1:
name | sale_id | sale_amnt | product |
---|---|---|---|
John | 03782 | 200 | tech |
Max | 87367 | 85 | clothes |
Beth | 63624 | 50 | home |
Max | 01873 | 500 | tech |
Jeff | 98077 | 300 | home |
Jeff | 87321 | 100 | clothes |
df2:
name | state | region |
---|---|---|
John | WI | USA |
Max | CA | USA |
Beth | CO | USA |
Jeff | NA | Canada |
This is the data frame that I am trying to create:
df3:
name | sale_id | sale_amnt | product | state | region |
---|---|---|---|---|---|
John | 03782 | 200 | tech | WI | USA |
Max | 87367 | 85 | clothes | CA | USA |
Beth | 63624 | 50 | home | CO | USA |
Max | 01873 | 500 | tech | WI | USA |
Jeff | 98077 | 300 | home | NA | Canada |
Jeff | 87321 | 100 | clothes | NA | Canada |
I tried using an outer join but that did not work. What should I be doing instead?