Open joshuaulrich opened 7 years ago
Note that you cannot currently do this with diff.zoo
in v1.8.0. You get the same error:
diff(zoo(.xts(1:5,1:5)), -(1:2), na.pad=TRUE)
Error in `-.default`(lag(x, k = -lag, ...), x) : non-conformable arrays
In addition: Warning message:
In if (lag > 0) for (i in 1:differences) x <- x - lag(x, k = -lag, :
the condition has length > 1 and only the first element will be used
You can pass a vector of lags to
lag.xts()
:You should be able to do the same with
diff.xts()
, but that currently throws an error:This might be as easy as coercing
x
to vector before subtracting the lags, but needs to be tested...