forked from tidyverse/dplyr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsummarise_each.Rd
69 lines (55 loc) · 2 KB
/
summarise_each.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/colwise.R
\name{summarise_each}
\alias{mutate_each}
\alias{mutate_each_}
\alias{mutate_each_q}
\alias{summarise_each}
\alias{summarise_each_}
\alias{summarise_each_q}
\alias{summarize_each}
\alias{summarize_each_}
\title{Summarise and mutate multiple columns.}
\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{
\item{tbl}{a tbl}
\item{funs}{List of function calls, generated by \code{\link{funs}}, or
a character vector of function names.}
\item{vars, ...}{Variables to include/exclude in mutate/summarise.
You can use same specifications as in \code{\link{select}}. If missing,
defaults to all non-grouping variables.
For standard evaluation versions (ending in \code{_}) these can
be either a list of expressions or a character vector.}
}
\description{
Apply one or more functions to one or more columns. Grouping variables
are always excluded from modification.
}
\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)))
}