I have to calculate the weight difference of the given dataset based on the previous row of each group ids.
For instance:
ID Wt
1 60.5
1 58
1 62
2 89
2 75
2 72
Expected Result:
ID Wt diff
1 60.5 2.5
1 58 -4
1 62
2 89 14
2 75 3
2 72
Kindly suggest code to solve the problem. Thanks in advance