-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shift type=cyclic #4451
Comments
Thank you for filling FR. It would help if you could provide a reproducible and minimal example of input and expected output, not just the syntax. |
I seems the me that you are asking about |
Thank you for your quick response. I will use an example close to the shift documentation:
I proposed to allow fill = x[(.N-a):.N]
Someone in #1708 also said they can't think of a real life example. I want to use it to shift prices from one market to another, to use them as instruments in estimating an "Almost Ideal Demand System" (AIDS). |
I had this in mind when writing the function, but didn't see much of a demand on SO or here. So postponed it at that time. It should be fairly straightforward to add this feature though. |
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.
The text was updated successfully, but these errors were encountered: