group_drop: Remove a Grouping Column from Groups

Description Usage Arguments See Also Examples

Description

Removes columns from the current list of groups, with the additional option to remove the columns from the data completely. In essence, the opposite of dplyr::group_by() with add = TRUE.

Usage

1
group_drop(.data, ..., .remove_dropped = FALSE)

Arguments

.data

A grouped tbl, tibble, or data.frame

...

Quoted or unquoted column names to be removed from the grouping

.remove_dropped

Should columns that are dropped from the grouping also be removed from .data? Default is FALSE.

See Also

Other Group Utilities: with_retain_groups, with_ungroup

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Remove "type" from the groups
tidyr::table2 %>%
  dplyr::group_by(country, year, type) %>%
  group_drop(type)

# Remove "type" from the groups and the output data frame
tidyr::table2 %>%
  dplyr::group_by(country, year, type) %>%
  group_drop(type, .remove_dropped = TRUE)

# Only columns that were dropped from groups will be removed
tidyr::table2 %>%
  dplyr::group_by(country, type) %>%
  group_drop(year, type, .remove_dropped = TRUE)

# Nothing happens if trying to drop a group that's not in the groups
tidyr::table2 %>%
  dplyr::group_by(country, year) %>%
  group_drop(type)

GerkeLab/fcds documentation built on July 30, 2020, 7:04 p.m.