Skip to content
Back to formatted view

Raw Message

Message-ID: <971536df0905181405j744e0068n9c7a8834489e9c59@mail.gmail.com>
Date: 2009-05-18T21:05:55Z
From: Gabor Grothendieck
Subject: Generic 'diff'
In-Reply-To: <8b356f880905181324l1c972889n4de2422fa787f6bd@mail.gmail.com>

You can define a new class for the object diff operates
on and then define your own diff method for that. For
some examples see:

methods(diff)



On Mon, May 18, 2009 at 4:24 PM, Stavros Macrakis <macrakis at alum.mit.edu> wrote:
> I would like to apply a function 'f' to the lagged version of a vector and
> the vector itself.
>
> This is easy to do explicitly:
>
> ? ? ?mapply( f, v[-1], v[-length(v)] )
>
> or in the case of a pointwise vector function, simply
>
> ? ? ?f( v[-1], v[-length(v)] )
>
> This is essentially the same as 'diff' but with an arbitrary function, not
> '-'.
>
> Is there a standard way to do this? Is there any particular reason that
> 'diff' should not have an 'f' argument?
>
> ? ? ? ? ? ?-s
>
> ? ? ? ?[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>