View source: R/garchx-source-code.R
| gdiff | R Documentation |
zoo objectsSimilar to the diff function from the base package, but gdiff enables padding (e.g. NAs or 0s) of the lost entries. Contrary to the diff function in the base package, however, the default in gdiff is to pad (with NAs). The gdiff function is particularly suited for zoo objects, since their indexing is retained
gdiff(x, lag = 1, pad = TRUE, pad.value = NA)
x |
a numeric vector or matrix |
lag |
integer equal to the difference-length (the default is 1) |
pad |
logical. If |
pad.value |
numeric, the pad-value |
A vector or matrix with the differenced values
Empty
Genaro Sucarrat, https://www.sucarrat.net/
diff, glag, lag
##1st difference of a series:
x <- rnorm(5)
gdiff(x)
##1st difference with no padding:
gdiff(x, pad=FALSE)
##1st difference retaining the original zoo-index ordering:
gdiff(as.zoo(x))
##1st difference of a matrix:
y <- matrix(rnorm(8),4,2)
gdiff(y)
##2nd difference of the same matrix:
gdiff(y, lag=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.