I have a dataframe with multiple columns and I would like to remove rows that do not meet a certain condition. I would like to only keep the rows that have a -1 followed by a 1 in the dataframe in one of the columns.
Example data.frame
column a column b
1 1 1
2 3 -1
3 8 1
4 10 -1
5 12 1
6 15 1
Example output:
column a column b
1 3 -1
2 8 1
3 10 -1
4 12 1
With
dplyr
you can use:Using this input data: