How to filter rows based on the previous row and keep previous row using dplyr?
问题 I am trying to subset rows of a data set using a condition that's based on the previous row, whilst keeping the previous row in the subsetted data. This is essentially the same as the question here, but I am looking for a dplyr approach: Select specific rows based on previous row value (in the same column) I have taken the dplyr approach applied in the comments to that answer, but I am unable to figure out the last step of retaining the previous row. I can get the rows that support the