I have the above table. I would like to fill in the missing values under Transaction ID. The algorithm for filling this would be as follows:
User ID "kenn1" has two missing Transaction IDs, and this can be filled using the other two Transaction IDs t1 and t4.
To choose which one to use between t1 and t4, I look at the Event Time. The first missing value happens at 9:30, and it is 30 minutes away from t1 and 20 minutes away from t4. Since t4 is closer to this missing value it would be filled as t4. Similarly for the missing value in row 4, it is 45 minutes away from t1 and 5 minutes away from t4. It would therefore be replaced with t4.
- Similar approach for missing values for User ID "kenn2"
How do I do this in R?