[R] A function slightly different from diff()

From: <dimitrijoe_at_ipea.gov.br>
Date: Thu 26 Jan 2006 - 12:24:14 EST


Hi,

I wonder if the following function has already been implemented in (some) R (package):

                summ <- function(x, lag=1) # x is a vector
                        {
                            n <- length(x)
                            x[(1+lag):n] + x[1:(n-lag)]
                        }

which (I think) the only difference from diff() is "+" instead of "-", for differences=1.

Thank you,
Dimitri Szerman



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jan 26 12:31:23 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:10 EST