summarize | R Documentation |
Aggregate data using summary statistics such as mean or median. Can be calculated by group.
summarize(
.df,
...,
.by = NULL,
.sort = TRUE,
.groups = "drop_last",
.unpack = FALSE
)
summarise(
.df,
...,
.by = NULL,
.sort = TRUE,
.groups = "drop_last",
.unpack = FALSE
)
.df |
A data.frame or data.table |
... |
Aggregations to perform |
.by |
Columns to group by.
|
.sort |
experimental: Default |
.groups |
Grouping structure of the result
|
.unpack |
experimental: Default |
df <- data.table(
a = 1:3,
b = 4:6,
c = c("a", "a", "b"),
d = c("a", "a", "b")
)
df %>%
summarize(avg_a = mean(a),
max_b = max(b),
.by = c)
df %>%
summarize(avg_a = mean(a),
.by = c(c, d))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.