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]


  x[-1]/x[-length(x)]

might be a little easier to understand.

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

______________________________________________
R-help@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.

Reply via email to