Re: [R] A function slightly different from diff()

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Thu 26 Jan 2006 - 12:59:41 EST

This isn't a single function but its a simple expression:

x <- ts(1:10) # test data
x + lag(x)

On 1/25/06, dimitrijoe@ipea.gov.br <dimitrijoe@ipea.gov.br> wrote:
> 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
>



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 13:08:07 2006

This archive was generated by hypermail 2.1.8 : Thu 26 Jan 2006 - 16:29:32 EST