Learn R Programming

tidytable (version 0.5.1)

summarize.: Aggregate data using summary statistics

Description

Aggregate data using summary statistics such as mean or median. Can be calculated by group.

Usage

summarize.(.df, ..., by = NULL)

summarise.(.df, ..., by = NULL)

dt_summarise(.df, ..., by = NULL)

dt_summarize(.df, ..., by = NULL)

Arguments

.df

A data.frame or data.table

...

Aggregations to perform

by

Columns to group by.

  • A single column can be passed with by = d.

  • Multiple columns can be passed with by = c(c, d)

  • tidyselect can be used:

    • Single predicate: by = where(is.character)

    • Multiple predicates: by = c(where(is.character), where(is.factor))

    • A combination of predicates and column names: by = c(where(is.character), b)

Examples

Run this code
# NOT RUN {
test_df <- data.table(
  a = c(1,2,3),
  b = c(4,5,6),
  c = c("a","a","b"),
  d = c("a","a","b"))

test_df %>%
  summarize.(avg_a = mean(a),
             max_b = max(b),
             by = c)

test_df %>%
  summarize.(avg_a = mean(a),
             by = c(c, d))
# }

Run the code above in your browser using DataLab