Rollapplyr and duplicated values

Viewed 9

I want to find duplicated elements and flag them in a rolling window. Does anyone know how to do it in r? For example, assume that I want to check whether value is repeated in the following 2 rows. I want to get something like this:

row_number value flag
1 2 TRUE
2 2 FALSE
3 1 FALSE
4 3 FALSE
5 2 TRUE
6 6 FALSE
6 2 FALSE
0 Answers
Related