Dear All, I am struggling to work this out and hoping if anyone could help me on this please? That is, when loc has either changed from left to right or changed from right to left, side will B and remains B throughout the end. In fact, I have used this dummy data for another question of mine yesterday flag and count by id when condition is met and was solved by Shmuel. I tried to tweak Shmuel's code but sadly no success. Thanking you in advance.
id vis test loc side
1 0 -
1 1 1 Left U
1 1 1 Right B
1 2 1 Left B
1 2 0 Right B
1 3 0 Left B
1 3 0 Right B
1 4 1 Left B
1 5 1 Left B
1 6 0 B
1 7 0 B
1 8 1 Left B
1 8 1 Left B
1 8 1 Right B
1 9 0 B
1 9 0 Right B
1 10 0 B
1 11 1 Left B
1 12 1 Left B
1 13 0 B
1 13 1 Right B
1 14 0 B
1 14 1 Right B
1 15 0 Left B
1 15 0 Right B
1 16 0 Left B
2 0 -
2 1 1 Left U
2 2 1 Left U
2 3 1 Left U
2 3 1 Right B
2 4 0 B
2 4 1 Right B
2 4 1 Right B
2 5 0 B
2 6 1 Left B
2 6 1 Right B
2 7 1 Left B
2 7 1 Right B
2 8 0 Left B
2 8 0 Right B
2 9 1 Left B
2 10 1 Left B
2 11 1 Left B
2 12 1 Left B
2 12 1 Right B
2 13 0 Left B
2 13 1 Right B
2 14 0 Left B
2 14 0 Right B
2 15 0 Left B
2 16 0 Left B
2 17 1 Left B
2 18 0 Left B
2 18 1 Right B
2 19 1 Left B
2 19 0 Right B
2 20 1 Left B
2 20 0 Right B
2 21 1 Left B
2 21 0 Right B
2 22 0 Left B
2 22 1 Right B
2 23 0 B
2 24 0 Left B
2 24 1 Right B
2 25 0 Left B
2 25 1 Right B
... View more