vctrs icon indicating copy to clipboard operation
vctrs copied to clipboard

Consider implementing `vec_collect_subscripts()`

Open DavisVaughan opened this issue 4 years ago • 2 comments

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.

DavisVaughan avatar May 14 '20 16:05 DavisVaughan

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 NULLs).

Also need to think about how to handle matrix subsetting.

hadley avatar May 14 '20 17:05 hadley

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.

krlmlr avatar Oct 24 '21 05:10 krlmlr