I have a data frame with a category column.
For each class within the category column, I would like a repeating sequence from 1 to n. For example, in the below table, for each unique value in the category column (e.g. a, b, c etc.), I would like to have a repeating sequence from 1 to 3 in the corresponding sequence column
| id | category | sequence |
|---|---|---|
| 1 | a | 1 |
| 2 | a | 2 |
| 3 | a | 3 |
| 4 | a | 1 |
| 5 | a | 2 |
| 6 | a | 3 |
| 7 | b | 1 |
| 8 | b | 2 |
| 9 | b | 3 |
| 10 | b | 1 |
| 11 | b | 2 |
| 12 | b | 3 |
I would very much appreciate any suggestions