ediff | R Documentation |
Often when creating lagged differences, it is awkward that the differences
vector is shorter than the original. ediff
pads with pad.value
to
make its output the same length as the input.
ediff(
x,
lag = 1,
differences = 1,
pad = c("head", "tail", "symmetric"),
pad.value = NA,
frontPad,
...
)
x |
a numeric vector or a matrix containing the values to be differenced |
lag |
an integer indicating which lag to use |
differences |
an integer indicating the order of the difference |
pad |
one of |
pad.value |
the value to be used for padding. |
frontPad |
logical indicating whether padding is on the front (head) or
back (tail) end. This exists for backward compatibility. New code should use
|
... |
further arguments to be passed to or from methods |
diff()
since
ediff
is a thin wrapper around diff()
.
ediff(1:10)
ediff(1:10, pad.value = 0)
ediff(1:10, 2)
ediff(1:10, 2, 2)
x <- cumsum(cumsum(1:10))
ediff(x, lag = 2)
ediff(x, differences = 2)
ediff(x, differences = 2, pad = "symmetric")
ediff(.leap.seconds)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.