I have a dataset that has a subject ID and different timepoints for each subject. I have the data filtered on few filters and want to create a new timepoint based on the existing timepoints for the subjects. The new point should be the difference between the First visit for the subject and the current visit. How can I do this in R ?
Sample data with expected result
| ID | Original_timepoint | New_timepoint |
|---|---|---|
| A | 1 | 1 |
| A | 6 | 6 |
| A | 18 | 18 |
| A | 36 | 36 |
| B | 24 | 1 |
| B | 48 | 24 |