Methods for computing lags and differences of
## S3 method for class 'zoo' lag(x, k = 1, na.pad = FALSE, ...) ## S3 method for class 'zoo' diff(x, lag = 1, differences = 1, arithmetic = TRUE, na.pad = FALSE, ...)
an integer indicating the order of the difference.
logical. Should arithmetic (or geometric) differences be computed?
currently not used.
These methods for
"zoo" objects behave analogously to the default
methods. The only additional arguments are
lag.zoo which can also be specified in
as part of the dots.
"k" can be a vector of lags in which case the names of
"k", if any, are used in naming the result.
The lagged or differenced
Note the sign of
k: a series lagged by a positive
is shifted earlier in time.
lag.zooreg can give different results.
For a lag of 1
lag.zoo moves points to the adjacent time point
lag.zooreg moves the time by
implies that a point in a
zoo series cannot be lagged to a time
point that is not already in the series whereas this is possible for
x <- zoo(11:21) lag(x, k = 1) lag(x, k = -1) # this pairs each value of x with the next or future value merge(x, lag1 = lag(x, k=1)) diff(x^3) diff(x^3, -1) diff(x^3, na.pad = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.