I have in R data frame that is divided to groups, like this:
Row | Group |
---|---|
1 | A |
2 | B |
3 | A |
4 | D |
5 | C |
6 | B |
7 | C |
8 | C |
9 | A |
10 | B |
I would like to add a uniaque numeric ID to each group, so finally I would have something like this:
Row | Group | ID |
---|---|---|
1 | A | 1 |
2 | B | 2 |
3 | A | 1 |
4 | D | 4 |
5 | C | 3 |
6 | B | 2 |
7 | C | 3 |
8 | C | 3 |
9 | A | 1 |
10 | B | 2 |
How could I achieve this?
Thank you very much.