I would like to find out the difference in days between the two date field based on the ID number. And the last date found based on ID would be 0 (Date - itself) Example a tibble dataframe:
| ID | Date | Difference |
|---|---|---|
| 1 | 1/1/2022 | 2 |
| 1 | 3/1/2022 | 0 |
| 2 | 2/1/2022 | 3 |
| 2 | 5/1/2022 | 23 |
| 2 | 28/1/2022 | 0 |
Is there any way to achieve this?