I have a dataset where I am trying to find the first instance in a consecutive set of rows that are identical. So let's say given this dataset:
df <- data.frame(trial = c(1:16), DV = c(2, 3, 2, 3, 3, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 1))
If I were looking for the first integer in df$DV
to repeat itself 5 times (for example), it would spit out "4".
I've tried a few things using the solutions found here (R: Selecting first of n consecutive rows above a certain threshold value), which is a similar problem, but I'm stuck. Any suggestions?
Thanks for your help in advance!