I have read excel file in R, where sheet1 has 51500 rows and 5 column and sheet 2 has user ID of buyers (only one column). Objective: Aim to extract the user in sheet_1 whose User Id are occurred in sheet 2. Here is the two example input files and desired output:
df <- data.frame(User.ID=c(12: 17), Group="Test", Spend=c(15:20), Purchase=c(5:10))
df
User.ID Group Spend Purchase
1 12 Test 15 5
2 13 Test 16 6
3 14 Test 17 7
4 15 Test 18 8
5 16 Test 19 9
6 17 Test 20 10
hash.ID <- data.frame(User.ID= c(13:16))
User.ID
1 13
2 14
3 15
4 16
desired output :
User.ID Group Spend Purchase Redem_Status
1 12 Test 15 5 Test_NonRedeemer
2 13 Test 16 6 Test_Redeemer
3 14 Test 17 7 Test_Redeemer
4 15 Test 18 8 Test_Redeemer
5 16 Test 19 9 Test_Redeemer
6 17 Test 20 10 Test_NonRedeemer
based on above example, we can see that if user Id from df is existed in hash.ID table, then we add new column and label it as Test_Redeemer, otherwise label it as Test_NonRedeemer. Is there any straightforward approach that can do this task ? Thanks a lot !!