Computes the first difference of a numeric vector or time series,
i.e. x_t - x_{t-1}. Gaps in dates are ignored; the difference is always
taken with respect to the immediately preceding observation.
Examples
firstdiff(c(1, 3, 6))
#> [1] NA 2 3
Computes the first difference of a numeric vector or time series,
i.e. x_t - x_{t-1}. Gaps in dates are ignored; the difference is always
taken with respect to the immediately preceding observation.
firstdiff(c(1, 3, 6))
#> [1] NA 2 3