I am looking for a solution related to R. In the below given data, I want to create sequence variable using status variable without sorting it. Same as the given example
Example,
| PID | Date | Status | Sequence |
|---|---|---|---|
| 1 | 12-9-2022 | A | 1 |
| 1 | 12-9-2022 | A | 1 |
| 1 | 12-9-2022 | B | 2 |
| 1 | 12-9-2022 | C | 3 |
| 1 | 12-9-2022 | C | 3 |
| 1 | 12-9-2022 | C | 3 |
| 1 | 12-9-2022 | A | 4 |
| 1 | 12-9-2022 | A | 4 |
| 1 | 12-9-2022 | A | 4 |
| 1 | 12-9-2022 | B | 5 |
| 1 | 12-9-2022 | B | 5 |
I have tried ample of conditions and loops but i am not able to find any solution.