Description Usage Arguments Value Note See Also Examples
Calculates differences between values with specified lag.
1 | differences(x, lag = 1, order = 1, na_padding = TRUE)
|
x |
A numeric vector containing the values for which returns are calculated. |
lag |
Integer indicating which lag to use (default: 1). |
order |
Order of differences (default: 1). |
na_padding |
Flag whether to pad truncated values with NA's (default: TRUE). |
Numeric vector with differences of specified lag and order.
Parameter na_padding
behaves slightly different from diff
in order to achieve consistency with lead
and lag
.
1 2 3 4 | differences(1:10)
differences(c(1, 2, 4, 8, 16, 32))
differences(c(1, 2, 4, 8, 16, 32), order = 2)
differences(c(1, 2, 4, 8, 16, 32), na_padding = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.