I'm trying to extract the rows each time there is a change in b :
a b
1 1 A
2 4 A
3 5 A
4 3 B
5 3 B
6 2 B
7 4 B
8 6 A
9 2 A
10 4 C
11 1 C
So the result i'm expecting would be :
a b
1 1 A
2 3 B
3 6 A
4 4 C
I thought on using the lag function in dplyr to extract the rows where the previous value of b is different but couldn't manage to do it...
Any help would be very appriciated!!