Reduces multiple values down to a single value

summarise() is typically used on grouped data created by group_by(). The output will have one row for each group.

summarise(.data, ...)

summarize(.data, ...)


A tbl. All main verbs are S3 generics and provide methods for tbl_df(), dtplyr::tbl_dt() and dbplyr::tbl_dbi().


Name-value pairs of summary functions. The name will be the name of the variable in the result. The value should be an expression that returns a single value like min(x), n(), or sum(

These arguments are automatically quoted and evaluated in the context of the data frame. They support unquoting and splicing. See vignette("programming") for an introduction to these concepts.


An object of the same class as .data. One grouping level will be dropped.

Useful functions

Backend variations

Data frames are the only backend that supports creating a variable and using it in the same summary. See examples for more details.

Tidy data

When applied to a data frame, row names are silently dropped. To preserve, convert to an explicit variable with tibble::rownames_to_column().

See Also

Other single table verbs: arrange, filter, mutate, select, slice

  • summarise
  • summarize
# A summary applied to ungrouped tbl returns a single row
mtcars %>%
  summarise(mean = mean(disp), n = n())

# Usually, you'll want to group first
mtcars %>%
  group_by(cyl) %>%
  summarise(mean = mean(disp), n = n())

# Each summary call removes one grouping level (since that group
# is now just a single row)
mtcars %>%
  group_by(cyl, vs) %>%
  summarise(cyl_n = n()) %>%

# Note that with data frames, newly created summaries immediately
# overwrite existing variables
mtcars %>%
  group_by(cyl) %>%
  summarise(disp = mean(disp), sd = sd(disp))

# summarise() supports quasiquotation. You can unquote raw
# expressions or quosures:
var <- quo(mean(cyl))
summarise(mtcars, !!var)
# }
Documentation reproduced from package dplyr, version 0.7.8, License: MIT + file LICENSE

Community examples at Sep 3, 2019 dplyr v0.7.8

mtcars %>% group_by(gear) %>% summarise(cor = cor(mpg, hp))

cielo_azzuro at Aug 4, 2019 dplyr v0.7.8

summarize(titanic, mean = mean(Age, na.rm=TRUE), sd = sd(Age, na.rm=TRUE)) The command above will generate a summary that includes the mean and standard deviation of the age of passengers in the freely-available Titanic data set. The argument na.rm=True ensures that empty cells are not included in the mean() and sd() calculations.