I want to filter rows from a data.frame based on where the values change.
Suppose I have:
id name quarter score
1. 01 john q1 2020 80
2. 01 john q2 2020 80
3. 01 john q3 2020 85
4. 01 john q4 2020 75
5. 02 adam q1 2020 80
6. 02 adam q2 2020 80
7. 02 adam q3 2020 85
8. 03 lana q1 2020 50
Wherever the quarter and score both change, I want to filter out those rows. So the data frame above should become,
id name quarter score
1. 01 john q2 2020 80
2. 01 john q3 2020 85
3. 01 john q4 2020 75
4. 02 adam q2 2020 80
5. 02 adam q3 2020 85
How do I compare the value of a cell with the value in the previous row in R?