Last chance! 50% off unlimited learning
Sale ends in
"zoo"
objects.## S3 method for class 'zoo':
lag(x, k = 1, na.pad = FALSE, \dots)
## S3 method for class 'zoo':
diff(x, lag = 1, differences = 1, arithmetic = TRUE, na.pad = FALSE, \dots)
"zoo"
object.k
behaves as in lag
.TRUE
it adds any times that would not otherwise have been in
the result with a value of NA
. If FALSE
those times are dropped."zoo"
object."zoo"
objects behave analogously to the default
methods. The only additional arguments are arithmetic
in diff
na.pad
in lag.zoo
which can also be specified in diff.zoo
as part of the dots.
Also, "k"
can be a vector of lags in which case the names of
"k"
, if any, are used in naming the result.zoo
, lag
, diff
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^2)
diff(x^2, na.pad = TRUE)
Run the code above in your browser using DataLab