shift(x, k=1)
NAs) are allowed.
k are rounded
to the nearest integer.
x,
but with positions lagged by
k steps.
The
shift function replaces
the old
lag function,
which illogically had the opposite sign of shifting.
The
lag function should be removed,
but due to its pervasive use in other functions, it is still there.
To compute a lagged/leading series with same time position but shifted data slot, use
seriesLag.
Use
seriesMerge to align the times
of several new-style time series.
Use
ts.intersect
or
ts.union to align the times of several
old-style time series.
shift is a generic function;
its default method calls
lag(x,-k).
shift
also has a method
for
series objects,
which works for both
timeSeries
and
signalSeries objects.
seriesLag function also works for both
timeSeries
and
signalSeries objects.
x <- signalSeries(data=data.frame(a=1:10, b=letters[1:10]), positions=1:10) x5 <- shift(x,5) seriesMerge(x, x5, pos="union")