[R] Subtraction loop
ecvetano at uwaterloo.ca
ecvetano at uwaterloo.ca
Mon Jun 28 17:22:43 CEST 2010
I have a data frame with 2 columns, one for day and one for average.
The day starts at 97 all the way to 279. I want to subtract day 98
average- day 97 average, then day99 average -day 98 average and so on
down my list, creating another column with the subtracted results.
I have:
Day DailyAverage
1 97 0.6076782
2 98 0.7121478
3 99 0.8059347
4 100 0.9545806
5 101 1.0589791
6 102 1.1335981
7 103 1.2676922
8 104 1.4429847
9 105 1.6477266
10 106 1.7970784
etc. with values to day 279
I'm guessing I need to create some kind of loop for this, but I am
unsure as to how to do this. Any help is greatly appreciated.
Thanks,
Emilija
More information about the R-help
mailing list