From: Thomas Petzoldt (email@example.com)
Date: Wed 26 May 2004 - 01:25:37 EST
Mag. Ferri Leberl wrote:
> How can I adress the current index of a vector?
> I want to work with time series and therefore give the n-th element of a
> vector some value dependent on the value of the n-1th element.
Sorry, your question is not really clear, but possibly the following may
1) If you have a vector x, you can create a shifted vector by removing
the first element, e.g.:
xnew <- x[-1] + somevalue # or apply a function f(x[-1])
2) The last element can be removed with:
xnew <- x[-length(x)]
3) ... and sometimes vector concatenation ?c or the ?ifelse function can
be useful in such circumstances.
PS: there is more about such things in the docs.
Rfirstname.lastname@example.org mailing list
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:12 EST