[R] Is there a funct to sum differences?

arthur brogard abrogard at yahoo.com
Sat Dec 24 00:40:18 CET 2016

I've been looking but I can't find a function to sum difference.

I have this code:

rates$thisone <- c(diff(rates$Int), NA)
rates$nextone <- c(diff(rates$Int, lag=2), NA, NA)
rates$lastone <- (rates$thisone + rates$nextone)

It is looking down one long column of numbers.

It sums the difference between the first two and then between the first and third and so on.

Can it be made to automatically sum the difference between the first and subsequent to the end of a list?

More information about the R-help mailing list