Skip to content
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

Rework lag() and lead() onto a common shift() helper #6336

Merged
merged 3 commits into from
Jul 18, 2022

Conversation

DavisVaughan
Copy link
Member

@DavisVaughan DavisVaughan commented Jul 16, 2022

Closes #6330

Using this as my starting point tidyverse/funs#34 (comment)

Main change in behavior is that now default is cast to the type of x rather than taking the common type. This ensures that these functions are type stable on x, which I feel like is a very important property here.

These functions already used vctrs in some capacity, but I was able to optimize it a little by separating out cases where the default is or is not supplied (when there is no default supplied, this is a simpler slice operation).

"dfba9805-5c9b-47a0-813d-9c781aba4b63"

@DavisVaughan DavisVaughan force-pushed the feature/lead-lag-update branch from d82619c to 881fb14 Compare July 18, 2022 14:03
@DavisVaughan DavisVaughan merged commit 0102132 into tidyverse:main Jul 18, 2022
@DavisVaughan DavisVaughan deleted the feature/lead-lag-update branch July 18, 2022 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lead() and lag() aren't type stable on x 😱
1 participant