summarise_each {dplyr} | R Documentation

## Summarise and mutate multiple columns.

### Description

Apply one or more functions to one or more columns. Grouping variables are always excluded from modification.

### Usage

    summarise_each(tbl, funs, ...)

    summarise_each_(tbl, funs, vars)

    summarize_each(tbl, funs, ...)

    summarize_each_(tbl, funs, vars)

    mutate_each(tbl, funs, ...)

    mutate_each_(tbl, funs, vars)

### Arguments

`tbl` | a tbl
`funs` | List of function calls, generated by `funs`, or a character vector of function names.
`vars,...` | Variables to include/exclude in mutate/summarise. You can use same specifications as in `select`. If missing, defaults to all non-grouping variables. For standard evaluation versions (ending in `_`) these can be either a list of expressions or a character vector.

### Examples

    # One function
    by_species <- iris %>% group_by(Species)
    by_species %>% summarise_each(funs(length))
    by_species %>% summarise_each(funs(mean))
    by_species %>% summarise_each(funs(mean), Petal.Width)
    by_species %>% summarise_each(funs(mean), matches("Width"))

    by_species %>% mutate_each(funs(half = . / 2))
    by_species %>% mutate_each(funs(min_rank))

    # Two functions
    by_species %>% summarise_each(funs(min, max))
    by_species %>% summarise_each(funs(min, max), Petal.Width, Sepal.Width)
    by_species %>% summarise_each(funs(min, max), matches("Width"))

    # Alternative function specification
    iris %>% summarise_each(funs(ul = length(unique(.))))
    by_species %>% summarise_each(funs(ul = length(unique(.))))

    by_species %>% summarise_each(c("min", "max"))

    # Alternative variable specification
    summarise_each_(iris, funs(max), names(iris)[-5])
    summarise_each_(iris, funs(max), list(quote(-Species)))

[Package dplyr version 0.4.3 Index]