vctrs
vctrs copied to clipboard
Consider implementing `vec_collect_subscripts()`
This could be the "bracket helper" mentioned in https://github.com/tidyverse/tibble/issues/768 and https://github.com/tidyverse/dplyr/issues/5161#issuecomment-621879379
We would essentially take all the code in standardize and move it all to vctrs.
I've tried it out in a branch of tibble and it seems to simplify the [
method without breaking anything https://github.com/DavisVaughan/tibble/commit/bfaec3f95b6beb4b520c830c8194781ed092ef90. The nicest part is that it removes all the confusing / hard to get right bits around missing()
and counting the number of supplied arguments.
We could maybe also add vec_collect_locations()
that would call vec_as_location()
on the subscripts as well, but I would still like to have a version that just "collects" the subscripts without modifying them in any way so that it can be as general as possible.
Yeah, I think vctrs is the right place for this code.
I definitely think we should have an additional function that takes the results of vec_collect_subscripts()
along with the column and row names, and returns integer vectors (or NULL
s).
Also need to think about how to handle matrix subsetting.
This is now available in standardize: https://github.com/DavisVaughan/standardize/. Would be great to have it to support https://github.com/tidyverse/tibble/issues/768 and https://github.com/tidyverse/tibble/issues/923.