[R] Deltas or changes

Ben Bolker bolker at ufl.edu
Tue Mar 9 15:02:47 CET 2010

Henrique Dallazuanna <wwwhsd <at> gmail.com> writes:

> Reduce("/", as.data.frame(embed(x, 2)))
> ManInMoon <xmoon2000 <at> googlemail.com> wrote:
> >
> > How can I generate a vector of differences between each 
> elemtn of an vector?

  (you mean ratios, right?)

> >
> > i.e. a[i]=x[i]/x[i-1]


might be a little easier to understand.

exp(diff(log(x)))  should work too (although
a big waste of computational power ...)

More information about the R-help mailing list