I would like to add a column that indicates if there are 2 duplicates observed in 2 rows in a dataframe. Let me give an example. Here is sample data.
df
id date n var
01-05 12-04-1985 1 sleep
02-06 11-04-2000 10 epoch
01-05 12-04-1985 1 epoch
12-10 01-08-2010 4 sleep
Note that rows 1 and 3 have the same id and date. I want to create an indicator in a new column (var) that has "sleep/epoch" for instances where the rows with id and date match, like so:
df
id date n var
01-05 12-04-1985 1 sleep/epoch
02-06 11-04-2000 10 epoch
01-05 12-04-1985 1 sleep/epoch
12-10 01-08-2010 4 sleep
I tried to do this using ifelse, but I had trouble doing so. Any advice on getting this to work?