Re: [R] Subtraction loop

2010-06-28 Thread Jonas Mandel
Hello, Check the function diff() it can do it for you, no need for a loop. Cheers, Jonas Mandel ecvet...@uwaterloo.ca a écrit : > 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,

[R] Subtraction loop

2010-06-28 Thread ecvetano
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 Da