You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like vctrs to add support for shift and partition operations.
vec_shift(x, amount, fill) — shifts the vector by positive or negative amount and fills up the gaps with fill. The result has the same size as the input. This is basically dplyr::lag() and dplyr::lead() and is useful for similar applications.
vec_partition(x, indices) — chops the vector into slices along the monotonously increasing sequence of indices. This is useful for inserting items at arbitrary locations in a vector. Examples:
I do think that would be useful as a helper outside of dplyr, but im not sure that vctrs is the right place for that one. We've got a long term goal of moving higher level (user facing) vector functions like that to https://github.com/tidyverse/funs
vec_partition() is similar to (possibly a duplicate of) #1210
Thanks, I missed #1210 when I was looking for similar stuff.
Personally, I think shifts and other advanced vector operations (e.g. compact) would be a great fit for vctrs, which already offers optimised advanced SIMD-style operations such as interleave and scatter/gather (vec_chop).
Activity
DavisVaughan commentedon Jul 27, 2022
FWIW the dplyr functions are now based on a common (not exposed)
shift()helperhttps://github.com/tidyverse/dplyr/blob/17c7a5d8d208f3c89d023c4735c14a74ee336dbd/R/lead-lag.R#L89
I do think that would be useful as a helper outside of dplyr, but im not sure that vctrs is the right place for that one. We've got a long term goal of moving higher level (user facing) vector functions like that to https://github.com/tidyverse/funs
vec_partition()is similar to (possibly a duplicate of) #1210tzakharko commentedon Jul 27, 2022
Thanks, I missed #1210 when I was looking for similar stuff.
Personally, I think shifts and other advanced vector operations (e.g. compact) would be a great fit for vctrs, which already offers optimised advanced SIMD-style operations such as interleave and scatter/gather (
vec_chop).