The monotone decreasing data I have is
ID Volume
0 98
1 84
2 75
3 64
4 54
5 42
6 36
7 25
8 0
Now I want to mutate new columns in R, which follows a calculation from this exist column.
New1 column is the previous volume minus the current volume.
New2 column is the current volume divide the previous volume. And the last cell of the new column is always 0 instead of NA.
I want to use mutate, but do not know what should be write within it.
ID Volume New1 New2
0 98 98-84 84/98
1 84 84-75 78/84
2 75 75-64 64/75
3 64 64-54 54/64
4 54 54-42 42/54
5 42 42-36 36/42
6 36 36-25 25/36
7 25 25-0 0/25
8 0 0