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?

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to