I want to transform a long and chronological dataset into a wide but chronological dataset by ID Let's see an example:
| ID | Product | Date |
|---|---|---|
| 1 | Bike | 1/1/2000 |
| 1 | Tire | 2/1/2000 |
| 2 | Car | 15/2/2000 |
| 2 | Seat | 17/2/2000 |
| 1 | Chronometer | 20/2/2000 |
Into the following table:
| ID | 1st | 2nd | 3rd | etc |
|---|---|---|---|---|
| 1 | Bike | Tire | Chronometer | |
| 2 | Car | Seat |
The order of the products bought must not be changed.
Can you help me guys?
Thanks a lot!
arrangethe data for eachIDandDate, give a unique row number for eachIDand cast the data to wide format.data