For e.g. tidyverse/dplyr#4504
vec_duplicate_split() gives exactly what is needed for a vctrs based implementation of group_by() , e.g.
library(dplyr)
d <- tibble(x = c(1, 1, 1, 1, 2, 2), y = c(1, 2, 1, 2, 1, 2), z = 1:6)
vctrs:::vec_duplicate_split(select(d, x, y))
#> $key
#> [1] 1 2 5 6
#>
#> $idx
#> $idx[[1]]
#> [1] 1 3
#>
#> $idx[[2]]
#> [1] 2 4
#>
#> $idx[[3]]
#> [1] 5
#>
#> $idx[[4]]
#> [1] 6
group_by(d, x, y) %>%
group_data()
#> # A tibble: 4 x 3
#> x y .rows
#> * <dbl> <dbl> <list>
#> 1 1 1 <int [2]>
#> 2 1 2 <int [2]>
#> 3 2 1 <int [1]>
#> 4 2 2 <int [1]>
key gives the indices I can use to vec_slice() the data to get the first columns
idx is exactly the .rows column
tidyverse/dplyr#4504 then goes a bit further to reveal empty groups when .drop = FALSE but that does not need to be vctrs' concern.
For e.g. tidyverse/dplyr#4504
vec_duplicate_split()gives exactly what is needed for avctrsbased implementation ofgroup_by(), e.g.keygives the indices I can use tovec_slice()the data to get the first columnsidxis exactly the.rowscolumntidyverse/dplyr#4504 then goes a bit further to reveal empty groups when
.drop = FALSEbut that does not need to bevctrs' concern.