I have a data frame, like this:
df <- data.frame (T = c(1:20), L = c(1,2,9,4,6,8,3,4,2,5,2,5,9,10,3,5,1,1,2,2))
I want to Flag a T value Ti (and also Ti−1 and Ti+1) if Li is bigger than 6 (i.e. 3 values in total are flagged then).
How to do it by Rollapply?