ungroup. | R Documentation |
group_by()
adds a grouping structure to a tidytable. Can use tidyselect syntax.
ungroup()
removes grouping.
ungroup.(.df, ...)
.df |
A data.frame or data.table |
... |
Columns to group by |
df <- data.table(
a = 1:3,
b = 4:6,
c = c("a", "a", "b"),
d = c("a", "a", "b")
)
df %>%
group_by(c, d) %>%
summarize(mean_a = mean(a)) %>%
ungroup()
# Can also use tidyselect
df %>%
group_by(where(is.character)) %>%
summarize(mean_a = mean(a)) %>%
ungroup()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.