# ----- use case 1 : on an already grouped tibble
ir <- iris %>%
group_by(Species)
group_split(ir)
group_keys(ir)
# this can be useful if the grouped data has been altered before the split
ir <- iris %>%
group_by(Species) %>%
filter(Sepal.Length > mean(Sepal.Length))
group_split(ir)
group_keys(ir)
# ----- use case 2: using a group_by() grouping specification
# both group_split() and group_keys() have to perform the grouping
# so it only makes sense to do this if you only need one or the other
iris %>%
group_split(Species)
iris %>%
group_keys(Species)
Run the code above in your browser using DataLab