date | product | serial_column |
---|---|---|
20/01/2021 | A | 1 |
21/01/2021 | A | 2 |
1/10/2020 | B | 1 |
2/10/2020 | B | 2 |
3/10/2020 | B | 3 |
4/10/2020 | B | 4 |
3/12/2020 | C | 1 |
4/12/2020 | C | 2 |
5/12/2020 | C | 3 |
29/11/2019 | D | 1 |
30/11/2019 | D | 2 |
I have a data frame like this (but without the serial_column), I would like to add this column. The data is sorted by date and grouped by products. How could I add the serial_column column? I would like to do it with the package dplyr
if it's possible.
Thanks.