[R] difference

Ashta sewashm at gmail.com
Fri Oct 28 06:20:15 CEST 2016


Hi all,

I want to calculate the difference  between successive row values to
the first row value within year.
How do I get that?

 Here is    the sample of data
Year   Num
2001    25
2001    75
2001   150
2002    30
2002    85
2002    95

Desired output
Year   Num  diff
2001    25       0
2001    75      50
2001  150    125
2002    30        0
2002    85      55
2002    95      65

Thank you.



More information about the R-help mailing list