The Syntax of shift() is
shift(x, n=1L, fill=NA, type=c("lag", "lead", "shift"), give.names=FALSE)
For n=1, one can use fill = x[.N] to put the last value on top of the column, so one can "rotate" the values by 1.
When n>2, x[.N] will only repeat the last value in all the places to fill. An for me intuitive way to use shift would be
n = a, fill = x[(.N-a):.N]
which should then continue this "rotating" behavior. If it is attempted, the result is
Error : fill must be a vector of length 1
I would greatly appreciate if you could incorporate this functionality.
The Syntax of shift() is
shift(x, n=1L, fill=NA, type=c("lag", "lead", "shift"), give.names=FALSE)For n=1, one can use fill = x[.N] to put the last value on top of the column, so one can "rotate" the values by 1.
When n>2, x[.N] will only repeat the last value in all the places to fill. An for me intuitive way to use shift would be
n = a, fill = x[(.N-a):.N]which should then continue this "rotating" behavior. If it is attempted, the result is
I would greatly appreciate if you could incorporate this functionality.