Returns a lagged/leading timeSeries
or signalSeries
object.
seriesLag(X, k = 1, trim = FALSE, pad = NA)
returns a lagged or leading time (signal) series of the original data.
an object of class timeSeries
or signalSeries
.
the number of positions the new time series or signal series is to lag or lead the input series, with a positive value resulting in a lagged series and a negative value resulting in a leading series.
a logical flag. If TRUE
, the missing values at the beginning or
end of the returned series will be trimmed. The default is
FALSE
.
any padding to fill in the beginning or ending missing values.
The default is NA
.
The difference between shift
and seriesLag
is
that the returned series of shift
is shifted in time (position
)
while the returned series of seriesLag
shifts the entire data slot
but keeps the same time (position
) intact.
They all work for both timeSeries
and signalSeries
objects.
lag
, shift
.
x <- timeSeries(data=data.frame(x=1:10, y=11:20),
from="7/4/2000", by="bizdays")
seriesLag(x, 1)
seriesLag(x, -1)
Run the code above in your browser using DataLab