group_by_everything_except: Group by all variables except some

Description Usage Arguments Value Examples

View source: R/utilities.R

Description

This is a convenience function that allows grouping of a data frame by all variables (columns) except those variables specified in ....

Usage

1
group_by_everything_except(.DF, ..., .add = FALSE, .drop = FALSE)

Arguments

.DF

a data frame to be grouped

...

a string, strings, vector of strings, or list of strings representing column names to be excluded from grouping

.add

When .add = FALSE, the default, dplyr::group_by() will override existing groups. To add to the existing groups, use .add = TRUE.

.drop

When .drop = TRUE, empty groups are dropped.

Value

a grouped version of .DF

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(dplyr)
DF <- data.frame(a = c(1, 2), b = c(3, 4), c = c(5, 6))
group_by_everything_except(DF) %>% group_vars()
group_by_everything_except(DF, NULL) %>% group_vars()
group_by_everything_except(DF, c()) %>% group_vars()
group_by_everything_except(DF, list()) %>% group_vars()
group_by_everything_except(DF, c) %>% group_vars()
group_by_everything_except(DF, "a") %>% group_vars()
group_by_everything_except(DF, "c") %>% group_vars()
group_by_everything_except(DF, c("a", "c")) %>% group_vars()
group_by_everything_except(DF, c("a")) %>% group_vars()
group_by_everything_except(DF, list("a")) %>% group_vars()

matsindf documentation built on Aug. 24, 2020, 5:09 p.m.