I have the following data
With dplyr:
dplyr
library(dplyr) your_data %>% mutate( Criteria = ifelse(lag(values, 1) > 5 & lag(values, 2) > 5, 1, 0) )
2.1m questions
2.1m answers
60 comments
57.0k users