Closed tzakharko closed 3 weeks ago
treating tables as row-iterable vectors
slider::slide()
does exactly that and is likely as close as we will get
https://slider.r-lib.org/articles/rowwise.html
It uses vctrs iteration under the hood and is mostly implemented in C to make it as fast as possible, but it still does have to callback to R to call the .f
function on every row
Thanks, @DavisVaughan! I was not aware that slider
is positioned as a general solution to this problem (my hope that there were plans for this in vctrs
or purrr
). I suppose that's another package to add to the dependency list :)
slider is well maintained and as lightweight dependency wise as purrr, so it should work pretty well for your use cases, I think!
It appreas that the ecosystem is still lacking a map primitive with
vctrs
-compatible semantics. I recall there was an effort to implement mapping as part of vctrs (e.g. #1227), which was abandoned in favour ofmap_vec()
inpurrr
. However,purrr
does not offervctrs
-compatible semantics, in particular it has inconsistent treatment of data frames (see for example https://github.com/tidyverse/purrr/issues/838).I believe that the
vctrs
approach to treating tables as row-iterable vectors is very powerful and allows the intuitive composition of complex data. This semantics also powers many advanced features withindplyr
. Are there plans to bring this to list iteration?