purrr <- c("p", "u", "r", "r", "r")
vec_group_id(purrr)
vec_group_rle(purrr)
groups <- mtcars[c("vs", "am")]
vec_group_id(groups)
group_rle <- vec_group_rle(groups)
group_rle
# Access fields with `field()`
field(group_rle, "group")
field(group_rle, "length")
# `vec_group_id()` is equivalent to
vec_match(groups, vec_unique(groups))
vec_group_loc(mtcars$vs)
vec_group_loc(mtcars[c("vs", "am")])
if (require("tibble")) {
as_tibble(vec_group_loc(mtcars[c("vs", "am")]))
}
Run the code above in your browser using DataLab