I have just been given 2 sales data frames; the main data frame houses all the information while the second has the latest sales for the month.
I need to merge the information from one data frame into the other based on a client's unique ID. Specifically, I would like to update information in the main data frame based on the new df.
I have tried using the merge function in R but have errors in replacing the information. I have done this merge in excel (but it takes a while since I have a lot of information).
The data frames looks a little like this...
MainDF
UID Status Gender SaleType
136273 inactive M Repair
182732 inactive F Product
298372 quit F Repair
283715 inactive M Product
NewDFtoAdd
UID Gender
136273 M
293827 F
283715 F
167643 M
I want to take the existing IDs in the main df and rewrite their status as 'active' if they appear in the NewDFtoAdd.
MainDF
UID Status Gender SaleType
136273 **active** M Repair
182732 inactive F Product
298372 quit F Repair
283715 **active** F Product
I really want to code this in R; so as new data is given I can just update accordingly and my analysis code can continue.