Description Usage Arguments See Also Examples
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
.
1 | group_drop(.data, ..., .remove_dropped = FALSE)
|
.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 |
Other Group Utilities: with_retain_groups
,
with_ungroup
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.