intersecting_group_by: Create a dataframe with groups mathing a range of predicates

View source: R/standalone-tidy-utils.R

intersecting_group_byR Documentation

Create a dataframe with groups mathing a range of predicates

Description

Create a new data frame including duplicate rows where the rows fulfil a potentially overlapping set of conditions specified as named predicates (as formulae)

Usage

intersecting_group_by(.data, ..., .colname)

Arguments

.data

a data frame

...

a set of predicates specified like case_whens syntax, such as mpg < 5 ~ "gas guzzlers"

.colname

the name of the new group

Value

a new dataframe containing the overlapping groups which may create duplicates of individual rows.

Examples

library(tidyverse)
iris %>% dplyr::group_by(Species) %>% intersecting_group_by(
  Sepal.Length > mean(Sepal.Length) ~ "Long",
  Sepal.Width > mean(Sepal.Width) ~ "Wide"
)

terminological/ggrrr documentation built on June 15, 2024, 6:35 a.m.